summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-02-19 10:38:02 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-02-19 10:38:18 +0000
commit678392aa6bef5e30cb1b9452978fd0b2ce56c2ee (patch)
tree26ac06227a6fe6571157a8860bac80506f00c5d7 /test
parentReleasing debian version 1.7.1-1. (diff)
downloadlibnvme-678392aa6bef5e30cb1b9452978fd0b2ce56c2ee.tar.xz
libnvme-678392aa6bef5e30cb1b9452978fd0b2ce56c2ee.zip
Merging upstream version 1.8.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test')
-rw-r--r--test/meson.build4
-rw-r--r--test/mi.c2
-rw-r--r--test/nbft/diffs/NBFT-Dell.PowerEdge.R660-fw1.5.5-single54
-rw-r--r--test/nbft/diffs/NBFT-Dell.PowerEdge.R76060
-rw-r--r--test/nbft/diffs/NBFT-auto-ipv61
-rw-r--r--test/nbft/diffs/NBFT-dhcp-ipv41
-rw-r--r--test/nbft/diffs/NBFT-dhcp-ipv61
-rw-r--r--test/nbft/diffs/NBFT-rhpoc1
-rw-r--r--test/nbft/diffs/NBFT-static-ipv41
-rw-r--r--test/nbft/diffs/NBFT-static-ipv4-discovery1
-rw-r--r--test/nbft/diffs/NBFT-static-ipv61
-rw-r--r--test/nbft/meson.build2
-rw-r--r--test/nbft/tables/NBFT-Dell.PowerEdge.R660-fw1.5.5-singlebin0 -> 930 bytes
l---------test/nbft/tables/NBFT-Dell.PowerEdge.R7601
-rw-r--r--test/sysfs/data/nvme-sysfs-tw-carbon-6.8.0-rc1+.out32
-rw-r--r--test/sysfs/data/nvme-sysfs-tw-carbon-6.8.0-rc1+.tar.xzbin0 -> 19712 bytes
-rw-r--r--test/sysfs/meson.build29
-rwxr-xr-xtest/sysfs/setup.sh11
-rw-r--r--test/sysfs/sysfs.c89
19 files changed, 283 insertions, 8 deletions
diff --git a/test/meson.build b/test/meson.build
index 2b4c6d8..93e6999 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -97,3 +97,7 @@ endif
subdir('ioctl')
subdir('nbft')
+
+if json_c_dep.found()
+ subdir('sysfs')
+endif
diff --git a/test/mi.c b/test/mi.c
index a09c108..a86ba15 100644
--- a/test/mi.c
+++ b/test/mi.c
@@ -306,7 +306,7 @@ static void test_invalid_crc(nvme_mi_ep_t ep)
test_set_transport_callback(ep, test_invalid_crc_cb, NULL);
rc = nvme_mi_mi_read_mi_data_subsys(ep, &ss_info);
- assert(rc != 0);
+ assert(rc < 0);
}
/* test: test that the controller list populates the endpoint's list of
diff --git a/test/nbft/diffs/NBFT-Dell.PowerEdge.R660-fw1.5.5-single b/test/nbft/diffs/NBFT-Dell.PowerEdge.R660-fw1.5.5-single
new file mode 100644
index 0000000..72a34de
--- /dev/null
+++ b/test/nbft/diffs/NBFT-Dell.PowerEdge.R660-fw1.5.5-single
@@ -0,0 +1,54 @@
+raw_nbft_size=930
+host.id=44454c4c44010448030b8c04f445833
+host.nqn=nqn.2014-08.org.nvmexpress:uuid:4c4c4544-0044-4410-8030-b8c04f445833
+host.host_id_configured=1
+host.host_nqn_configured=1
+host.primary=0
+hfi_list[0]->index=1
+hfi_list[0]->transport=tcp
+hfi_list[0]->tcp_info.pci_sbdf=27136
+hfi_list[0]->tcp_info.mac_addr=062bcbeb70
+hfi_list[0]->tcp_info.vlan=0
+hfi_list[0]->tcp_info.ip_origin=94
+hfi_list[0]->tcp_info.ipaddr=172.18.240.1
+hfi_list[0]->tcp_info.subnet_mask_prefix=24
+hfi_list[0]->tcp_info.gateway_ipaddr=0.0.0.0
+hfi_list[0]->tcp_info.route_metric=500
+hfi_list[0]->tcp_info.primary_dns_ipaddr=0.0.0.0
+hfi_list[0]->tcp_info.secondary_dns_ipaddr=0.0.0.0
+hfi_list[0]->tcp_info.dhcp_server_ipaddr=
+hfi_list[0]->tcp_info.host_name=(null)
+hfi_list[0]->tcp_info.this_hfi_is_default_route=1
+hfi_list[0]->tcp_info.dhcp_override=0
+subsystem_ns_list[0]->index=1
+subsystem_ns_list[0]->num_hfis=1
+subsystem_ns_list[0]->hfis[0]->index=1
+subsystem_ns_list[0]->transport=tcp
+subsystem_ns_list[0]->traddr=172.18.240.60
+subsystem_ns_list[0]->trsvcid=4420
+subsystem_ns_list[0]->subsys_port_id=0
+subsystem_ns_list[0]->nsid=270
+subsystem_ns_list[0]->nid_type=2
+subsystem_ns_list[0]->nid=5380b42fc0c5de718ccf9680be3ca7
+subsystem_ns_list[0]->subsys_nqn=nqn.1988-11.com.dell:powerstore:00:88b402df2d762AA7AF94
+subsystem_ns_list[0]->pdu_header_digest_required=0
+subsystem_ns_list[0]->data_digest_required=0
+subsystem_ns_list[0]->controller_id=4105
+subsystem_ns_list[0]->asqsz=0
+subsystem_ns_list[0]->dhcp_root_path_string=(null)
+subsystem_ns_list[1]->index=2
+subsystem_ns_list[1]->num_hfis=1
+subsystem_ns_list[1]->hfis[0]->index=1
+subsystem_ns_list[1]->transport=tcp
+subsystem_ns_list[1]->traddr=172.18.240.60
+subsystem_ns_list[1]->trsvcid=4420
+subsystem_ns_list[1]->subsys_port_id=0
+subsystem_ns_list[1]->nsid=1671
+subsystem_ns_list[1]->nid_type=2
+subsystem_ns_list[1]->nid=f4c66fce74afdb8ccf96807eaeae
+subsystem_ns_list[1]->subsys_nqn=nqn.1988-11.com.dell:powerstore:00:88b402df2d762AA7AF94
+subsystem_ns_list[1]->pdu_header_digest_required=0
+subsystem_ns_list[1]->data_digest_required=0
+subsystem_ns_list[1]->controller_id=4105
+subsystem_ns_list[1]->asqsz=0
+subsystem_ns_list[1]->dhcp_root_path_string=(null)
diff --git a/test/nbft/diffs/NBFT-Dell.PowerEdge.R760 b/test/nbft/diffs/NBFT-Dell.PowerEdge.R760
new file mode 100644
index 0000000..d7fab3f
--- /dev/null
+++ b/test/nbft/diffs/NBFT-Dell.PowerEdge.R760
@@ -0,0 +1,60 @@
+raw_nbft_size=1017
+host.id=44454c4c34010368038b2c04f313233
+host.nqn=nqn.1988-11.com.dell:PowerEdge.R760.1234567
+host.host_id_configured=1
+host.host_nqn_configured=1
+host.primary=0
+hfi_list[0]->index=1
+hfi_list[0]->transport=tcp
+hfi_list[0]->tcp_info.pci_sbdf=16384
+hfi_list[0]->tcp_info.mac_addr=b02628e87ce
+hfi_list[0]->tcp_info.vlan=0
+hfi_list[0]->tcp_info.ip_origin=82
+hfi_list[0]->tcp_info.ipaddr=100.71.245.232
+hfi_list[0]->tcp_info.subnet_mask_prefix=24
+hfi_list[0]->tcp_info.gateway_ipaddr=100.71.245.254
+hfi_list[0]->tcp_info.route_metric=500
+hfi_list[0]->tcp_info.primary_dns_ipaddr=100.64.0.5
+hfi_list[0]->tcp_info.secondary_dns_ipaddr=100.64.0.6
+hfi_list[0]->tcp_info.dhcp_server_ipaddr=100.71.245.254
+hfi_list[0]->tcp_info.host_name=(null)
+hfi_list[0]->tcp_info.this_hfi_is_default_route=1
+hfi_list[0]->tcp_info.dhcp_override=1
+discovery_list[0]->index=1
+discovery_list[0]->hfi->index=1
+discovery_list[0]->uri=nvme+tcp://100.71.103.50:8009/
+discovery_list[0]->nqn=nqn.2014-08.org.nvmexpress.discovery
+subsystem_ns_list[0]->index=1
+subsystem_ns_list[0]->discovery->index=1
+subsystem_ns_list[0]->num_hfis=1
+subsystem_ns_list[0]->hfis[0]->index=1
+subsystem_ns_list[0]->transport=tcp
+subsystem_ns_list[0]->traddr=100.71.103.48
+subsystem_ns_list[0]->trsvcid=4420
+subsystem_ns_list[0]->subsys_port_id=0
+subsystem_ns_list[0]->nsid=148
+subsystem_ns_list[0]->nid_type=2
+subsystem_ns_list[0]->nid=c8244ed9c15f53b8ccf96802efca
+subsystem_ns_list[0]->subsys_nqn=nqn.1988-11.com.dell:powerstore:00:2a64abf1c5b81F6C4549
+subsystem_ns_list[0]->pdu_header_digest_required=0
+subsystem_ns_list[0]->data_digest_required=0
+subsystem_ns_list[0]->controller_id=5
+subsystem_ns_list[0]->asqsz=0
+subsystem_ns_list[0]->dhcp_root_path_string=(null)
+subsystem_ns_list[1]->index=2
+subsystem_ns_list[1]->discovery->index=1
+subsystem_ns_list[1]->num_hfis=1
+subsystem_ns_list[1]->hfis[0]->index=1
+subsystem_ns_list[1]->transport=tcp
+subsystem_ns_list[1]->traddr=100.71.103.49
+subsystem_ns_list[1]->trsvcid=4420
+subsystem_ns_list[1]->subsys_port_id=0
+subsystem_ns_list[1]->nsid=148
+subsystem_ns_list[1]->nid_type=2
+subsystem_ns_list[1]->nid=c8244ed9c15f53b8ccf96802efca
+subsystem_ns_list[1]->subsys_nqn=nqn.1988-11.com.dell:powerstore:00:2a64abf1c5b81F6C4549
+subsystem_ns_list[1]->pdu_header_digest_required=0
+subsystem_ns_list[1]->data_digest_required=0
+subsystem_ns_list[1]->controller_id=4166
+subsystem_ns_list[1]->asqsz=0
+subsystem_ns_list[1]->dhcp_root_path_string=(null)
diff --git a/test/nbft/diffs/NBFT-auto-ipv6 b/test/nbft/diffs/NBFT-auto-ipv6
index 32a8b60..83ee643 100644
--- a/test/nbft/diffs/NBFT-auto-ipv6
+++ b/test/nbft/diffs/NBFT-auto-ipv6
@@ -23,7 +23,6 @@ hfi_list[0]->tcp_info.dhcp_override=0
subsystem_ns_list[0]->index=1
subsystem_ns_list[0]->num_hfis=1
subsystem_ns_list[0]->hfis[0]->index=1
-subsystem_ns_list[0]->hfis[1]->index=1
subsystem_ns_list[0]->transport=tcp
subsystem_ns_list[0]->traddr=fd09:9a46:b5c1:1ff:5054:ff:fefd:9e66
subsystem_ns_list[0]->trsvcid=4420
diff --git a/test/nbft/diffs/NBFT-dhcp-ipv4 b/test/nbft/diffs/NBFT-dhcp-ipv4
index cb280d9..067079d 100644
--- a/test/nbft/diffs/NBFT-dhcp-ipv4
+++ b/test/nbft/diffs/NBFT-dhcp-ipv4
@@ -28,7 +28,6 @@ subsystem_ns_list[0]->index=1
subsystem_ns_list[0]->discovery->index=1
subsystem_ns_list[0]->num_hfis=1
subsystem_ns_list[0]->hfis[0]->index=1
-subsystem_ns_list[0]->hfis[1]->index=1
subsystem_ns_list[0]->transport=tcp
subsystem_ns_list[0]->traddr=192.168.49.10
subsystem_ns_list[0]->trsvcid=4420
diff --git a/test/nbft/diffs/NBFT-dhcp-ipv6 b/test/nbft/diffs/NBFT-dhcp-ipv6
index b94cc39..11c974f 100644
--- a/test/nbft/diffs/NBFT-dhcp-ipv6
+++ b/test/nbft/diffs/NBFT-dhcp-ipv6
@@ -23,7 +23,6 @@ hfi_list[0]->tcp_info.dhcp_override=1
subsystem_ns_list[0]->index=1
subsystem_ns_list[0]->num_hfis=1
subsystem_ns_list[0]->hfis[0]->index=1
-subsystem_ns_list[0]->hfis[1]->index=1
subsystem_ns_list[0]->transport=tcp
subsystem_ns_list[0]->traddr=fddf:d:f:49::10
subsystem_ns_list[0]->trsvcid=4420
diff --git a/test/nbft/diffs/NBFT-rhpoc b/test/nbft/diffs/NBFT-rhpoc
index d4b4ad8..d849b6e 100644
--- a/test/nbft/diffs/NBFT-rhpoc
+++ b/test/nbft/diffs/NBFT-rhpoc
@@ -23,7 +23,6 @@ hfi_list[0]->tcp_info.dhcp_override=0
subsystem_ns_list[0]->index=1
subsystem_ns_list[0]->num_hfis=1
subsystem_ns_list[0]->hfis[0]->index=1
-subsystem_ns_list[0]->hfis[1]->index=1
subsystem_ns_list[0]->transport=tcp
subsystem_ns_list[0]->traddr=192.168.101.20
subsystem_ns_list[0]->trsvcid=4420
diff --git a/test/nbft/diffs/NBFT-static-ipv4 b/test/nbft/diffs/NBFT-static-ipv4
index 715b30d..a6f3859 100644
--- a/test/nbft/diffs/NBFT-static-ipv4
+++ b/test/nbft/diffs/NBFT-static-ipv4
@@ -23,7 +23,6 @@ hfi_list[0]->tcp_info.dhcp_override=0
subsystem_ns_list[0]->index=1
subsystem_ns_list[0]->num_hfis=1
subsystem_ns_list[0]->hfis[0]->index=1
-subsystem_ns_list[0]->hfis[1]->index=1
subsystem_ns_list[0]->transport=tcp
subsystem_ns_list[0]->traddr=192.168.49.10
subsystem_ns_list[0]->trsvcid=4420
diff --git a/test/nbft/diffs/NBFT-static-ipv4-discovery b/test/nbft/diffs/NBFT-static-ipv4-discovery
index 67881b6..5bf0e46 100644
--- a/test/nbft/diffs/NBFT-static-ipv4-discovery
+++ b/test/nbft/diffs/NBFT-static-ipv4-discovery
@@ -28,7 +28,6 @@ subsystem_ns_list[0]->index=1
subsystem_ns_list[0]->discovery->index=1
subsystem_ns_list[0]->num_hfis=1
subsystem_ns_list[0]->hfis[0]->index=1
-subsystem_ns_list[0]->hfis[1]->index=1
subsystem_ns_list[0]->transport=tcp
subsystem_ns_list[0]->traddr=192.168.49.10
subsystem_ns_list[0]->trsvcid=4420
diff --git a/test/nbft/diffs/NBFT-static-ipv6 b/test/nbft/diffs/NBFT-static-ipv6
index a5b02c1..c6ad844 100644
--- a/test/nbft/diffs/NBFT-static-ipv6
+++ b/test/nbft/diffs/NBFT-static-ipv6
@@ -23,7 +23,6 @@ hfi_list[0]->tcp_info.dhcp_override=0
subsystem_ns_list[0]->index=1
subsystem_ns_list[0]->num_hfis=1
subsystem_ns_list[0]->hfis[0]->index=1
-subsystem_ns_list[0]->hfis[1]->index=1
subsystem_ns_list[0]->transport=tcp
subsystem_ns_list[0]->traddr=fd09:9a46:b5c1:1fe::13f
subsystem_ns_list[0]->trsvcid=4420
diff --git a/test/nbft/meson.build b/test/nbft/meson.build
index 67b2d95..919bf83 100644
--- a/test/nbft/meson.build
+++ b/test/nbft/meson.build
@@ -18,6 +18,8 @@ tables = [
'NBFT-static-ipv4',
'NBFT-static-ipv4-discovery',
'NBFT-static-ipv6',
+ 'NBFT-Dell.PowerEdge.R760',
+ 'NBFT-Dell.PowerEdge.R660-fw1.5.5-single'
]
tables_bad = [
diff --git a/test/nbft/tables/NBFT-Dell.PowerEdge.R660-fw1.5.5-single b/test/nbft/tables/NBFT-Dell.PowerEdge.R660-fw1.5.5-single
new file mode 100644
index 0000000..845a8e2
--- /dev/null
+++ b/test/nbft/tables/NBFT-Dell.PowerEdge.R660-fw1.5.5-single
Binary files differ
diff --git a/test/nbft/tables/NBFT-Dell.PowerEdge.R760 b/test/nbft/tables/NBFT-Dell.PowerEdge.R760
new file mode 120000
index 0000000..2e5c8dc
--- /dev/null
+++ b/test/nbft/tables/NBFT-Dell.PowerEdge.R760
@@ -0,0 +1 @@
+../../../libnvme/tests/NBFT \ No newline at end of file
diff --git a/test/sysfs/data/nvme-sysfs-tw-carbon-6.8.0-rc1+.out b/test/sysfs/data/nvme-sysfs-tw-carbon-6.8.0-rc1+.out
new file mode 100644
index 0000000..1cb6de4
--- /dev/null
+++ b/test/sysfs/data/nvme-sysfs-tw-carbon-6.8.0-rc1+.out
@@ -0,0 +1,32 @@
+{
+ "hosts":[
+ {
+ "hostnqn":"nqn.2014-08.org.nvmexpress:uuid:ce4fee3e-c02c-11ee-8442-830d068a36c6",
+ "hostid":"ce4fee3e-c02c-11ee-8442-830d068a36c6",
+ "subsystems":[
+ {
+ "name":"nvme-subsys1",
+ "nqn":"nqn.2019-08.org.qemu:nvme-0",
+ "controllers":[
+ {
+ "name":"nvme1",
+ "transport":"pcie",
+ "traddr":"0000:00:05.0"
+ }
+ ]
+ },
+ {
+ "name":"nvme-subsys0",
+ "nqn":"nqn.2019-08.org.qemu:subsys1",
+ "controllers":[
+ {
+ "name":"nvme0",
+ "transport":"pcie",
+ "traddr":"0000:0f:00.0"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+}
diff --git a/test/sysfs/data/nvme-sysfs-tw-carbon-6.8.0-rc1+.tar.xz b/test/sysfs/data/nvme-sysfs-tw-carbon-6.8.0-rc1+.tar.xz
new file mode 100644
index 0000000..ee11fde
--- /dev/null
+++ b/test/sysfs/data/nvme-sysfs-tw-carbon-6.8.0-rc1+.tar.xz
Binary files differ
diff --git a/test/sysfs/meson.build b/test/sysfs/meson.build
new file mode 100644
index 0000000..c004fc0
--- /dev/null
+++ b/test/sysfs/meson.build
@@ -0,0 +1,29 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+#
+# This file is part of libnvme.
+# Copyright (c) 2024 SUSE LLC.
+#
+# Authors: Daniel Wagner <dwagner@suse.de>
+
+
+sysfs = executable(
+ 'test-sysfs',
+ ['sysfs.c'],
+ dependencies: libnvme_dep,
+ include_directories: [incdir, internal_incdir]
+)
+
+sysfs_files= [
+ 'nvme-sysfs-tw-carbon-6.8.0-rc1+'
+]
+
+setup = find_program('setup.sh')
+
+foreach t_file : sysfs_files
+ r = run_command(setup, files('data'/t_file + '.tar.xz'), meson.current_build_dir(), check: true)
+ i = r.stdout().strip()
+ e0 = 'LIBNVME_SYSFS_PATH=' + i
+ e1 = 'LIBNVME_HOSTNQN=nqn.2014-08.org.nvmexpress:uuid:ce4fee3e-c02c-11ee-8442-830d068a36c6'
+ e2 = 'LIBNVME_HOSTID=ce4fee3e-c02c-11ee-8442-830d068a36c6'
+ test('sysfs', sysfs, args : [ i, t_file + '.out', files('data'/t_file + '.out') ], env : [ e0, e1, e2 ])
+endforeach
diff --git a/test/sysfs/setup.sh b/test/sysfs/setup.sh
new file mode 100755
index 0000000..3437d4e
--- /dev/null
+++ b/test/sysfs/setup.sh
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+TARFILE=$1
+BASEDIR=$2
+TESTDIR="$BASEDIR/$(basename -s .tar.xz ${TARFILE})"
+
+mkdir -p "${TESTDIR}"
+tar -x -f "${TARFILE}" -C "${TESTDIR}" || exit 1
+
+echo "${TESTDIR}"
diff --git a/test/sysfs/sysfs.c b/test/sysfs/sysfs.c
new file mode 100644
index 0000000..c2df178
--- /dev/null
+++ b/test/sysfs/sysfs.c
@@ -0,0 +1,89 @@
+// SPDX-License-Identifier: LGPL-2.1-or-later
+/**
+ * This file is part of libnvme.
+ * Copyright (c) 2024 Daniel Wagner, SUSE LLC
+ */
+
+#include "nvme/tree.h"
+#include <assert.h>
+#include <errno.h>
+#include <string.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <arpa/inet.h>
+
+#include <ccan/array_size/array_size.h>
+
+#include <libnvme.h>
+#include <nvme/private.h>
+
+static bool test_sysfs(const char *path, const char *filename)
+{
+ FILE *f;
+ nvme_root_t r;
+ int err;
+
+ f = fopen(filename, "w");
+ if (!f)
+ return false;
+
+ r = nvme_create_root(f, LOG_ERR);
+ assert(r);
+
+ err = nvme_scan_topology(r, NULL, NULL);
+ if (!err)
+ nvme_dump_tree(r);
+ fprintf(f, "\n");
+
+ nvme_free_tree(r);
+ fclose(f);
+
+ return err == 0;
+}
+
+static bool compare_content(const char *filename1, const char *filename2)
+{
+ FILE *f1, *f2;
+ char c1, c2;
+ bool pass = false;
+
+ f1 = fopen(filename1, "r");
+ if (!f1)
+ return false;
+
+ f2 = fopen(filename2, "r");
+ if (!f2) {
+ fclose(f1);
+ return false;
+ }
+
+ do {
+ c1 = getc(f1);
+ c2 = getc(f2);
+ if (c1 != c2)
+ goto out;
+ } while (c1 != EOF || c2 != EOF);
+
+ if (c1 == c2)
+ pass = true;
+out:
+ fclose(f1);
+ fclose(f2);
+
+ return pass;
+}
+
+int main(int argc, char *argv[])
+{
+ bool pass = true;
+
+ if (argc < 4) {
+ fprintf(stderr, "usage: test-sysfs SYSFS_DIR OUTPUT_FILE COMPARE_FILE\n");
+ return EXIT_FAILURE;
+ }
+
+ pass &= test_sysfs(argv[1], argv[2]);
+ pass &= compare_content(argv[2], argv[3]);
+
+ exit(pass ? EXIT_SUCCESS : EXIT_FAILURE);
+}