1{
2 lib,
3 writeText,
4 runCommand,
5 tsm-client,
6}:
7
8# Let the client try to connect to a server.
9# We can't simulate a server, so there's no more to test.
10
11let
12
13 # 192.0.0.8 is a "dummy address" according to RFC 7600
14 dsmSysCli = writeText "cli.dsm.sys" ''
15 defaultserver testserver
16 server testserver
17 commmethod v6tcpip
18 tcpserveraddress 192.0.0.8
19 nodename ARBITRARYNODENAME
20 '';
21
22 tsm-client_ = tsm-client.override { inherit dsmSysCli; };
23
24 env.nativeBuildInputs = [ tsm-client_ ];
25
26 versionString =
27 let
28 inherit (tsm-client_.passthru.unwrapped) version;
29 major = lib.versions.major version;
30 minor = lib.versions.minor version;
31 patch = lib.versions.patch version;
32 fixup = lib.lists.elemAt (lib.versions.splitVersion version) 3;
33 in
34 "Client Version ${major}, Release ${minor}, Level ${patch}.${fixup}";
35
36in
37
38runCommand "${tsm-client.name}-test-cli" env ''
39 set -o nounset
40 set -o pipefail
41
42 export DSM_LOG=$(mktemp -d ./dsm_log.XXXXXXXXXXX)
43
44 { dsmc -optfile=/dev/null || true; } | tee dsmc-stdout
45
46 # does it report the correct version?
47 grep --fixed-strings '${versionString}' dsmc-stdout
48
49 # does it use the provided dsm.sys config file?
50 # if it does, it states the node's name
51 grep ARBITRARYNODENAME dsmc-stdout
52
53 # does it try (and fail) to connect to the server?
54 # if it does, it reports the "TCP/IP connection failure" error code
55 grep ANS1017E dsmc-stdout
56 grep ANS1017E $DSM_LOG/dsmerror.log
57
58 touch $out
59''