Commit graph

56 commits

Author SHA1 Message Date
9da6c3f31b test.expect(): Add support for Cmd class array
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
59b0c60aee os.misc.cmd_exec(): Support NoWaitForNewline
Remove newlines argument from cmd_exec(), which wasn't honoured
anyway, and replace it with the more generic flags argument in
conjunction with support for the NoWaitForNewline flag, which does
the obvious.

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
1740f3c5c8 os.test.ListCmd: Add self.__write_raw_response - half done
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
6c06abffe9 os.Machine: Rename virtual power functions
Rename for consistency:

    wait_poweroff -> wait_power_off()

 Now, here's what we have:

    request_power_on(self)
    wait_up(self, timeout)
    request_shutdown(self)
    request_power_off(self)
    wait_power_off(self, timeout)

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
2dcf5a2cf4 os.test.main.py: Rename to os.test.test.py
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
7e106811b2 os.conn.Serial: Attempt to fix closing of invalid file descriptor
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
a194dc7c0d fixup! test.ListCmd: Add support for output processing
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
e752a67e13 fixup! devtest.os.test.test.py: Rename to main.my
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
d65a9313bc devtest.os.test.ListCmd.py: Fix import from test.py
Python 3.10 considers get_console unknown after "from devtest.os.test
import *", and "from devtest.os.test import get_console" raises

  ImportError: cannot import name 'get_console' from partially
  initialized module 'devtest.os.test' (most likely due to a circular
  import) (/home/user/local/src/jw.dev/jw-devtest/src/python/devtest/os/test/__init__.py)

This has worked up until Python 3.8.
Solved by changing "from devtest.os.test" to "from .test"

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
e7d2abedf0 devtest.os.test.test.py: Rename to main.my
Renaming test.test.py to main.py, since Python apparently has a
problem if file names equal module names. This has worked up until
Python 3.8.  Python 3.10, however, considers get_console unknown
after "from devtest.os.test import *", and "from devtest.os.test
import get_console" raises

  ImportError: cannot import name 'get_console' from partially
  initialized module 'devtest.os.test' (most likely due to a circular
  import) (/home/user/local/src/jw.dev/jw-devtest/src/python/devtest/os/test/__init__.py)

Solved by renaming test/test.py to test/main.py.

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
b4bbe7bc9a fixup! os.test.ListCmd: Add response output convenience symlink
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
3ab8a70523 project.conf: Fix pkg.requires.os syntax
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
dcb3fc3cab be.shellcmd: Support cmd.xxx options in --be-opts
Allow to override the default shell commands used to start and stop
the machine with custom commands, as in

   --be-opts="cmd.request-power-on='/usr/bin/power.sh something'"

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
3c9c5f1769 os.Environment, os.Machine: Add --be-opts
--be-opts is a means to pass machine-backend-specific options to that
backend.

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
dccb75246a os.Environment, os.MachineCmd: Add --tag, --time-stamp
Add support for options --tag and --time-stamp to MachineCmd, and
store them in Environment.tag and .time_stamp, respectively.

.time_stamp defaults to current time if --time-stamp is not present.

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
069e1dee1a test.expect(): Use Connection.Flags.ReadOnlyPrintable
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
368d81cb3f os.Connection.read(): Support ReadOnlyPrintable
Add flag ReadOnlyPrintable and support it in read(). This omits all
characters not in string.printable from read()'s result.

This comes in handy if systemd spits out bouncing start-job-running
asterisks which find their way back to the reader but close the shell
on him.

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
817ac6aef1 TcScript.__create(): TODO: Use transfer.put()
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
3ee70eb9b5 Add os.transfer
Add module os.transfer, notably sporting the put() function.

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
f7542eff89 os.test.ListCmd: Add response output convenience symlink
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
6da9e6af00 test.cmd_expect(): Add support for echo_cmd command line arg
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
2a7267a004 test.expect(): Add support for log_act command line arg
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
162c5c9f63 os.CmdTestOs: Log test failures in multiple lines
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
cf9dc2a392 test.ListCmd: Beautify fail output
Make fail return a multi-line experience, possibly breaking grep, so
try out if this is a good idea.

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
476f501fbe test.ListCmd: Reduce debug logging
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
e11f626971 test.ListCmd: Add methods items() and field_keys()
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
31152ec718 test.ListCmd: Use ListCmd._row_name() for displaying stuff
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
fe8d9c0300 test.ListCmd: Fix option match logic
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
745dfa2737 test.ListCmd: Append environment time stamp to output files
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
cecd749ce9 cases.ProcessList: Beautify _row_name()
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
e43deb371e os.Environment: Add field time_stamp
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
22de74795b test.ListCmd: Make row comparison faster (TODO: Not active)
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
e0b3cc41ce test.ListCmd: Add support for refpath lists
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
ca3b597341 Add test.cases.Audit
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
dc40decb96 ListCmd.py: Make Rows sortable
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
3fba1c2a89 os.CmdTestOs: Add support for --phases argument
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
174286e3cc TestPhases: Add phases spec alias "All"
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
b5d849ce44 Add test/audit
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
8d62ea3939 jw-devtest.py: Code beautification
Just for the heck of it: Make it even shorter.

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:27 +01:00
1592ea933c os.Environment: Add method conf_value()
Since all command instances carry config information from
~/.jw-devtestrc, make it available via a dedicated conf_value()
method to all interested test cases.

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:26 +01:00
ab8b04ad30 os.Connection._read(): Safeguard against non-utf8
Don't try to decode non-UTF-8 garbage as UTF-8 if it shows up in _read().

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:26 +01:00
6239c0546a test.expect(): Add support for cmd keyword argument
expect now takes a cmd argument, which defaults to None, and which
runs the command over the given connection before it takes to waiting
for a matching regex to be sent.

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:26 +01:00
50abdbb3c7 os.CmdTestOs: Beautify test summary
Log a greppable summary of all failed tests in one line at the end of
the output.

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:26 +01:00
86a6939688 os.TestResults: Beautify dump()
Test results are now output via slog(), and are decorated with a
count of failed and total tests.

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:26 +01:00
82bb65b6c0 os.CmdTestOs: Add get_ run_ test_cases() and friend
Make the private CmdTestOs.__run_test_cases() method available to
external code interested in running a selection of test cases.

This is useful, e.g. for re-running a failed firmware installation
encapsulated in a test case from inside another test case.

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:26 +01:00
d747aa78d5 os.TestResutls: Add method addResults()
Add method addResults(), which allows to merge results of another
TestResults instance into the called instance.

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:26 +01:00
6e04ffdcbe os.be.*.Machine: Rename CPU -> DUT
Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:26 +01:00
1c674dfa3f Add test.cmds_exec()
test.cmds_exec() takes a list of lists with commands to be sent to a
console, returns None on success and an error message on failure.

The list can consist of up to three entries, 2 + 3 are optional:

  [ cmd, expect-regex, timeout]

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:26 +01:00
7d709ecc58 os.misc.cmd_exec(): Fix echo_cmd=False
cmd_exec() sometimes returned the command in the output albeit
echo_cmd=False was specified, notably if the command contained a
newline.

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:26 +01:00
0f723cfd1b test.cases.ProcMounts: Add ":" to device name regex
Devices may be called ubi0:rescue0 or so.

Signed-off-by: Jan Lindemann <jan@janware.com>
2025-11-17 11:12:26 +01:00