Class: Yast::TestsuiteClass

Inherits:
Module
  • Object
show all
Defined in:
../../src/modules/Testsuite.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) Dump(output)

Dump value to the testsuite output (keyword: Dump)

Parameters:

  • output (Object)

    whatever to be dumped into the log



73
74
75
76
77
78
79
80
81
82
83
84
85
# File '../../src/modules/Testsuite.rb', line 73

def Dump(output)
  output = deep_copy(output)
  out = Builtins.sformat("%1", output)
  lines = Builtins.splitstring(out, "\n")
  Builtins.maplist(lines) do |l|
    Builtins.y2debug("%1Dump\t%2", @dummy_log_string, l)
  end
  if Ops.less_than(Builtins.size(lines), 1)
    Builtins.y2debug("%1Dump\t%2", @dummy_log_string, out)
  end

  nil
end

- (Object) DumpFile(filename)

Dump file contents to the testsuite output (keyword: File)

Parameters:

  • filename (String)

    file to be dumped



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File '../../src/modules/Testsuite.rb', line 89

def DumpFile(filename)
  command = Builtins.sformat(
    "/bin/cat \"%1\" | sed \"s/^/%2File\t/\"",
    filename,
    @dummy_log_string
  )

  SCR.RegisterAgent(path(".target"), "/usr/share/YaST2/scrconf/target.scr")
  res = Convert.to_map(SCR.Execute(path(".target.bash_output"), command))
  SCR.UnregisterAllAgents

  out = Ops.get_string(res, "stdout", " (nil)")
  lines = Builtins.splitstring(out, "\n")
  Builtins.maplist(lines) { |l| Builtins.y2debug("%1", l) }
  if Ops.less_than(Builtins.size(lines), 1)
    Builtins.y2debug("%1File\t%2", @dummy_log_string, out)
  end

  nil
end

- (Array) Init(_INPUT, _DEFAULT)

Returns of various SCR return values

Parameters:

  • INPUT (Array)

    a tuple of read, write and execute maps

  • DEFAULT (Object)

    default read value

Returns:

  • (Array)

    of various SCR return values



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File '../../src/modules/Testsuite.rb', line 23

def Init(_INPUT, _DEFAULT)
  _INPUT = deep_copy(_INPUT)
  _DEFAULT = deep_copy(_DEFAULT)
  defaultv = {}

  read = Ops.get(_INPUT, 0, defaultv)
  write = Ops.get(_INPUT, 1, defaultv)
  exec = Ops.get(_INPUT, 2, defaultv)

  Builtins.y2debug("READ=%1", read)
  Builtins.y2debug("WRITE=%1", write)
  Builtins.y2debug("EXECUTE=%1", exec)
  Builtins.y2debug("DEFAULT=%1", _DEFAULT)

  # initialize
  ret = []
  ret = Builtins.add(ret, SCR.UnregisterAllAgents)
  ret = Builtins.add(
    ret,
    SCR.RegisterAgent(
      path("."),
      term(:ag_dummy, term(:DataMap, read, write, exec, _DEFAULT))
    )
  )
  Builtins.y2debug("ret=%1", ret)

  deep_copy(ret)
end

- (Object) main



13
14
15
16
17
18
# File '../../src/modules/Testsuite.rb', line 13

def main

  # Secret string :-)
  @dummy_log_string = "LOGTHIS_SECRET_314 "
  Testsuite()
end

- (Object) Test(_FUNCTION, _INPUT, _DEFAULT)

Returns whatever the FUNCTION returns

Parameters:

  • FUNCTION (Object)

    a single or deep quoted term

  • INPUT (Array)

    a tuple of read, write and execute maps

  • DEFAULT (Object)

    default read value

Returns:

  • whatever the FUNCTION returns



56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File '../../src/modules/Testsuite.rb', line 56

def Test(_FUNCTION, _INPUT, _DEFAULT)
  _FUNCTION = deep_copy(_FUNCTION)
  _INPUT = deep_copy(_INPUT)
  _DEFAULT = deep_copy(_DEFAULT)
  Builtins.y2debug("FUNCTION=%1", _FUNCTION)

  Init(_INPUT, _DEFAULT)

  real_ret = Builtins.eval(_FUNCTION)

  Builtins.y2debug("%1Return\t%2", @dummy_log_string, real_ret)

  deep_copy(real_ret)
end

- (Object) Testsuite

Constructor (initialize SCR with dummy agent)



111
112
113
114
115
# File '../../src/modules/Testsuite.rb', line 111

def Testsuite
  Init([], nil)

  nil
end