mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-02 03:43:06 +00:00
f6dca95c5d
The tsm-client needs a tsm-server to do anything useful. Without a server, automated tests can just check diagnostic outputs for plausibility. The commit at hand adds two tests: 1. The command line interface `dsmc` is called, then it is verified that the program does * report the correct client version, * find its configuration file, * report a connection error. 2. To check the GUI (and the tsm-client nixos module), we add a vm test which uses the module to install `tsm-client-withGui`. To verify that the GUI's basic functionality is present, we skip over all connection failure related error messages and open the "Connection Information" dialog from the main application window. This dialog presents the node name and the client version; both are verified by the test. Note: Our `tsm-client` build recipe consists of two packages: The "unwrapped" package and the final package. This commit puts the unwrapped one into the final package's `passthru` so that tests can access the original version string that is needed to check the client version reported by the application.
59 lines
1.5 KiB
Nix
59 lines
1.5 KiB
Nix
{ lib
|
|
, writeText
|
|
, runCommand
|
|
, tsm-client
|
|
}:
|
|
|
|
# Let the client try to connect to a server.
|
|
# We can't simulate a server, so there's no more to test.
|
|
|
|
let
|
|
|
|
# 192.0.0.8 is a "dummy address" according to RFC 7600
|
|
dsmSysCli = writeText "cli.dsm.sys" ''
|
|
defaultserver testserver
|
|
server testserver
|
|
commmethod v6tcpip
|
|
tcpserveraddress 192.0.0.8
|
|
nodename ARBITRARYNODENAME
|
|
'';
|
|
|
|
tsm-client_ = tsm-client.override { inherit dsmSysCli; };
|
|
|
|
env.nativeBuildInputs = [ tsm-client_ ];
|
|
|
|
versionString =
|
|
let
|
|
inherit (tsm-client_.passthru.unwrapped) version;
|
|
major = lib.versions.major version;
|
|
minor = lib.versions.minor version;
|
|
patch = lib.versions.patch version;
|
|
fixup = lib.lists.elemAt (lib.versions.splitVersion version) 3;
|
|
in
|
|
"Client Version ${major}, Release ${minor}, Level ${patch}.${fixup}";
|
|
|
|
in
|
|
|
|
runCommand "${tsm-client.name}-test-cli" env ''
|
|
set -o nounset
|
|
set -o pipefail
|
|
|
|
export DSM_LOG=$(mktemp -d ./dsm_log.XXXXXXXXXXX)
|
|
|
|
{ dsmc -optfile=/dev/null || true; } | tee dsmc-stdout
|
|
|
|
# does it report the correct version?
|
|
grep --fixed-strings '${versionString}' dsmc-stdout
|
|
|
|
# does it use the provided dsm.sys config file?
|
|
# if it does, it states the node's name
|
|
grep ARBITRARYNODENAME dsmc-stdout
|
|
|
|
# does it try (and fail) to connect to the server?
|
|
# if it does, it reports the "TCP/IP connection failure" error code
|
|
grep ANS1017E dsmc-stdout
|
|
grep ANS1017E $DSM_LOG/dsmerror.log
|
|
|
|
touch $out
|
|
''
|