Files
nixpkgs/pkgs/by-name/ts/tsm-client/test-cli.nix
Silvan Mosberger 667d42c00d treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build a08b3a4d19.tar.gz \
      --argstr baseRev 57b193d8dd
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:27:17 +01:00

60 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
''