summaryrefslogtreecommitdiffstats
path: root/test/nbft
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 19:22:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 19:22:29 +0000
commit068a45420f2c98887e220b45e946cc7074da550e (patch)
treec5b54e8b4b235232b057a9c534d9a16d2208463d /test/nbft
parentInitial commit. (diff)
downloadlibnvme-068a45420f2c98887e220b45e946cc7074da550e.tar.xz
libnvme-068a45420f2c98887e220b45e946cc7074da550e.zip
Adding upstream version 1.8.upstream/1.8
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/nbft')
-rw-r--r--test/nbft/README17
-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-ipv638
-rw-r--r--test/nbft/diffs/NBFT-dhcp-ipv443
-rw-r--r--test/nbft/diffs/NBFT-dhcp-ipv638
-rw-r--r--test/nbft/diffs/NBFT-rhpoc38
-rw-r--r--test/nbft/diffs/NBFT-static-ipv438
-rw-r--r--test/nbft/diffs/NBFT-static-ipv4-discovery43
-rw-r--r--test/nbft/diffs/NBFT-static-ipv638
-rwxr-xr-xtest/nbft/gen-nbft-diffs.sh.in5
-rw-r--r--test/nbft/meson.build85
-rwxr-xr-xtest/nbft/nbft-dump-diff.sh.in8
-rw-r--r--test/nbft/nbft-dump.c121
-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/nbft/tables/NBFT-auto-ipv6bin0 -> 721 bytes
-rw-r--r--test/nbft/tables/NBFT-dhcp-ipv4bin0 -> 825 bytes
-rw-r--r--test/nbft/tables/NBFT-dhcp-ipv6bin0 -> 725 bytes
-rw-r--r--test/nbft/tables/NBFT-rhpocbin0 -> 724 bytes
-rw-r--r--test/nbft/tables/NBFT-static-ipv4bin0 -> 725 bytes
-rw-r--r--test/nbft/tables/NBFT-static-ipv4-discoverybin0 -> 825 bytes
-rw-r--r--test/nbft/tables/NBFT-static-ipv6bin0 -> 721 bytes
-rw-r--r--test/nbft/tables_bad/NBFT-bad-oldspecbin0 -> 1103 bytes
-rw-r--r--test/nbft/tables_bad/NBFT-random-noisebin0 -> 512 bytes
25 files changed, 627 insertions, 0 deletions
diff --git a/test/nbft/README b/test/nbft/README
new file mode 100644
index 0000000..0f252a5
--- /dev/null
+++ b/test/nbft/README
@@ -0,0 +1,17 @@
+This is a simple testcase to verify the NBFT parser output over a set
+of provided ACPI NBFT tables.
+
+The 'nbft-dump' test utility is a simple tool to print out all elements
+and nested arrays of the nbft_info structs, bearing only minimal logic.
+
+The 'tables' directory contains sample binary files taken from
+/sys/firmware/acpi/tables. The 'tables_bad' then contains experiments, older
+table revisions or malformed data to test the parser error path.
+
+The "diffs" directory contains reference output generated by the 'nbft-dump'
+utility that is being compared against actual testcase run output. Everytime
+'nbft-dump.c' is modified these reference output files need to be regenerated
+by calling `ninja -C .build nbft-diffs` over the configured meson project.
+
+The tests are typically ran as part of the standard `meson test -C .build`
+invocation.
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
new file mode 100644
index 0000000..83ee643
--- /dev/null
+++ b/test/nbft/diffs/NBFT-auto-ipv6
@@ -0,0 +1,38 @@
+raw_nbft_size=721
+host.id=1ee8b170eb4c864fb7957d179e201a
+host.nqn=nqn.2014-08.org.nvmexpress:uuid:70b1e81e-4ceb-4f86-b709-57d1079e201a
+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=512
+hfi_list[0]->tcp_info.mac_addr=525409e201a
+hfi_list[0]->tcp_info.vlan=0
+hfi_list[0]->tcp_info.ip_origin=1
+hfi_list[0]->tcp_info.ipaddr=fd09:9a46:b5c1:1ff:5054:ff:fe9e:201a
+hfi_list[0]->tcp_info.subnet_mask_prefix=64
+hfi_list[0]->tcp_info.gateway_ipaddr=::
+hfi_list[0]->tcp_info.route_metric=0
+hfi_list[0]->tcp_info.primary_dns_ipaddr=::
+hfi_list[0]->tcp_info.secondary_dns_ipaddr=::
+hfi_list[0]->tcp_info.dhcp_server_ipaddr=
+hfi_list[0]->tcp_info.host_name=nvmepoc-sles15-sp5
+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=fd09:9a46:b5c1:1ff:5054:ff:fefd:9e66
+subsystem_ns_list[0]->trsvcid=4420
+subsystem_ns_list[0]->subsys_port_id=0
+subsystem_ns_list[0]->nsid=1
+subsystem_ns_list[0]->nid_type=3
+subsystem_ns_list[0]->nid=848f4dc06d394968bf180569b8eea97
+subsystem_ns_list[0]->subsys_nqn=nqn.2022-12.de.suse.mwilck:zeus.vagrant-nvmet.subsys04
+subsystem_ns_list[0]->pdu_header_digest_required=0
+subsystem_ns_list[0]->data_digest_required=0
+subsystem_ns_list[0]->controller_id=1
+subsystem_ns_list[0]->asqsz=0
+subsystem_ns_list[0]->dhcp_root_path_string=(null)
diff --git a/test/nbft/diffs/NBFT-dhcp-ipv4 b/test/nbft/diffs/NBFT-dhcp-ipv4
new file mode 100644
index 0000000..067079d
--- /dev/null
+++ b/test/nbft/diffs/NBFT-dhcp-ipv4
@@ -0,0 +1,43 @@
+raw_nbft_size=825
+host.id=e359b7a15d37747b3cc1754b8b819b9
+host.nqn=nqn.2014-08.org.nvmexpress:uuid:a1b759e3-035d-4777-b3cc-1754b8b819b9
+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=8
+hfi_list[0]->tcp_info.mac_addr=52540b819b9
+hfi_list[0]->tcp_info.vlan=0
+hfi_list[0]->tcp_info.ip_origin=3
+hfi_list[0]->tcp_info.ipaddr=192.168.49.155
+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=0
+hfi_list[0]->tcp_info.primary_dns_ipaddr=192.168.49.1
+hfi_list[0]->tcp_info.secondary_dns_ipaddr=0.0.0.0
+hfi_list[0]->tcp_info.dhcp_server_ipaddr=192.168.49.1
+hfi_list[0]->tcp_info.host_name=nvmeof-sles
+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://192.168.49.10:4420/
+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=192.168.49.10
+subsystem_ns_list[0]->trsvcid=4420
+subsystem_ns_list[0]->subsys_port_id=0
+subsystem_ns_list[0]->nsid=1
+subsystem_ns_list[0]->nid_type=3
+subsystem_ns_list[0]->nid=df669a88bd6f4dd68a505f97eb55c835
+subsystem_ns_list[0]->subsys_nqn=nqn.2022-12.org.nvmexpress.boot.poc:bremer.vagrant-nvmet.subsys02
+subsystem_ns_list[0]->pdu_header_digest_required=0
+subsystem_ns_list[0]->data_digest_required=0
+subsystem_ns_list[0]->controller_id=7
+subsystem_ns_list[0]->asqsz=0
+subsystem_ns_list[0]->dhcp_root_path_string=(null)
diff --git a/test/nbft/diffs/NBFT-dhcp-ipv6 b/test/nbft/diffs/NBFT-dhcp-ipv6
new file mode 100644
index 0000000..11c974f
--- /dev/null
+++ b/test/nbft/diffs/NBFT-dhcp-ipv6
@@ -0,0 +1,38 @@
+raw_nbft_size=725
+host.id=e359b7a15d37747b3cc1754b8b819b9
+host.nqn=nqn.2014-08.org.nvmexpress:uuid:a1b759e3-035d-4777-b3cc-1754b8b819b9
+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=8
+hfi_list[0]->tcp_info.mac_addr=52540b819b9
+hfi_list[0]->tcp_info.vlan=0
+hfi_list[0]->tcp_info.ip_origin=3
+hfi_list[0]->tcp_info.ipaddr=fddf:d:f:49::eb
+hfi_list[0]->tcp_info.subnet_mask_prefix=64
+hfi_list[0]->tcp_info.gateway_ipaddr=::
+hfi_list[0]->tcp_info.route_metric=0
+hfi_list[0]->tcp_info.primary_dns_ipaddr=::
+hfi_list[0]->tcp_info.secondary_dns_ipaddr=::
+hfi_list[0]->tcp_info.dhcp_server_ipaddr=::
+hfi_list[0]->tcp_info.host_name=nvmeof-sles
+hfi_list[0]->tcp_info.this_hfi_is_default_route=1
+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]->transport=tcp
+subsystem_ns_list[0]->traddr=fddf:d:f:49::10
+subsystem_ns_list[0]->trsvcid=4420
+subsystem_ns_list[0]->subsys_port_id=0
+subsystem_ns_list[0]->nsid=1
+subsystem_ns_list[0]->nid_type=3
+subsystem_ns_list[0]->nid=df669a88bd6f4dd68a505f97eb55c835
+subsystem_ns_list[0]->subsys_nqn=nqn.2022-12.org.nvmexpress.boot.poc:bremer.vagrant-nvmet.subsys02
+subsystem_ns_list[0]->pdu_header_digest_required=0
+subsystem_ns_list[0]->data_digest_required=0
+subsystem_ns_list[0]->controller_id=34
+subsystem_ns_list[0]->asqsz=0
+subsystem_ns_list[0]->dhcp_root_path_string=(null)
diff --git a/test/nbft/diffs/NBFT-rhpoc b/test/nbft/diffs/NBFT-rhpoc
new file mode 100644
index 0000000..d849b6e
--- /dev/null
+++ b/test/nbft/diffs/NBFT-rhpoc
@@ -0,0 +1,38 @@
+raw_nbft_size=724
+host.id=b4bb164e7f9be448c7f77d8b4fc9f39
+host.nqn=nqn.2014-08.org.nvmexpress:uuid:f8131bac-cdef-4165-866b-5998c1e67890
+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=40
+hfi_list[0]->tcp_info.mac_addr=eaebd3588958
+hfi_list[0]->tcp_info.vlan=0
+hfi_list[0]->tcp_info.ip_origin=1
+hfi_list[0]->tcp_info.ipaddr=192.168.101.30
+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=0
+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=host-vm
+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=192.168.101.20
+subsystem_ns_list[0]->trsvcid=4420
+subsystem_ns_list[0]->subsys_port_id=0
+subsystem_ns_list[0]->nsid=1
+subsystem_ns_list[0]->nid_type=3
+subsystem_ns_list[0]->nid=bee9c2b7176144b5a4e6f69498a94b
+subsystem_ns_list[0]->subsys_nqn=nqn.2014-08.org.nvmexpress:uuid:0c468c4d-a385-47e0-8299-6e95051277db
+subsystem_ns_list[0]->pdu_header_digest_required=0
+subsystem_ns_list[0]->data_digest_required=0
+subsystem_ns_list[0]->controller_id=12
+subsystem_ns_list[0]->asqsz=0
+subsystem_ns_list[0]->dhcp_root_path_string=(null)
diff --git a/test/nbft/diffs/NBFT-static-ipv4 b/test/nbft/diffs/NBFT-static-ipv4
new file mode 100644
index 0000000..a6f3859
--- /dev/null
+++ b/test/nbft/diffs/NBFT-static-ipv4
@@ -0,0 +1,38 @@
+raw_nbft_size=725
+host.id=e359b7a15d37747b3cc1754b8b819b9
+host.nqn=nqn.2014-08.org.nvmexpress:uuid:a1b759e3-035d-4777-b3cc-1754b8b819b9
+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=8
+hfi_list[0]->tcp_info.mac_addr=52540b819b9
+hfi_list[0]->tcp_info.vlan=0
+hfi_list[0]->tcp_info.ip_origin=1
+hfi_list[0]->tcp_info.ipaddr=192.168.49.50
+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=0
+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=nvmeof-sles
+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=192.168.49.10
+subsystem_ns_list[0]->trsvcid=4420
+subsystem_ns_list[0]->subsys_port_id=0
+subsystem_ns_list[0]->nsid=1
+subsystem_ns_list[0]->nid_type=3
+subsystem_ns_list[0]->nid=df669a88bd6f4dd68a505f97eb55c835
+subsystem_ns_list[0]->subsys_nqn=nqn.2022-12.org.nvmexpress.boot.poc:bremer.vagrant-nvmet.subsys02
+subsystem_ns_list[0]->pdu_header_digest_required=0
+subsystem_ns_list[0]->data_digest_required=0
+subsystem_ns_list[0]->controller_id=38
+subsystem_ns_list[0]->asqsz=0
+subsystem_ns_list[0]->dhcp_root_path_string=(null)
diff --git a/test/nbft/diffs/NBFT-static-ipv4-discovery b/test/nbft/diffs/NBFT-static-ipv4-discovery
new file mode 100644
index 0000000..5bf0e46
--- /dev/null
+++ b/test/nbft/diffs/NBFT-static-ipv4-discovery
@@ -0,0 +1,43 @@
+raw_nbft_size=825
+host.id=e359b7a15d37747b3cc1754b8b819b9
+host.nqn=nqn.2014-08.org.nvmexpress:uuid:a1b759e3-035d-4777-b3cc-1754b8b819b9
+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=8
+hfi_list[0]->tcp_info.mac_addr=52540b819b9
+hfi_list[0]->tcp_info.vlan=0
+hfi_list[0]->tcp_info.ip_origin=1
+hfi_list[0]->tcp_info.ipaddr=192.168.49.50
+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=0
+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=nvmeof-sles
+hfi_list[0]->tcp_info.this_hfi_is_default_route=1
+hfi_list[0]->tcp_info.dhcp_override=0
+discovery_list[0]->index=1
+discovery_list[0]->hfi->index=1
+discovery_list[0]->uri=nvme+tcp://192.168.49.10:4420/
+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=192.168.49.10
+subsystem_ns_list[0]->trsvcid=4420
+subsystem_ns_list[0]->subsys_port_id=0
+subsystem_ns_list[0]->nsid=1
+subsystem_ns_list[0]->nid_type=3
+subsystem_ns_list[0]->nid=df669a88bd6f4dd68a505f97eb55c835
+subsystem_ns_list[0]->subsys_nqn=nqn.2022-12.org.nvmexpress.boot.poc:bremer.vagrant-nvmet.subsys02
+subsystem_ns_list[0]->pdu_header_digest_required=0
+subsystem_ns_list[0]->data_digest_required=0
+subsystem_ns_list[0]->controller_id=13
+subsystem_ns_list[0]->asqsz=0
+subsystem_ns_list[0]->dhcp_root_path_string=(null)
diff --git a/test/nbft/diffs/NBFT-static-ipv6 b/test/nbft/diffs/NBFT-static-ipv6
new file mode 100644
index 0000000..c6ad844
--- /dev/null
+++ b/test/nbft/diffs/NBFT-static-ipv6
@@ -0,0 +1,38 @@
+raw_nbft_size=721
+host.id=1ee8b170eb4c864fb7957d179e201a
+host.nqn=nqn.2014-08.org.nvmexpress:uuid:70b1e81e-4ceb-4f86-b709-57d1079e201a
+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=512
+hfi_list[0]->tcp_info.mac_addr=525409e201a
+hfi_list[0]->tcp_info.vlan=0
+hfi_list[0]->tcp_info.ip_origin=1
+hfi_list[0]->tcp_info.ipaddr=fd09:9a46:b5c1:1fe::10
+hfi_list[0]->tcp_info.subnet_mask_prefix=64
+hfi_list[0]->tcp_info.gateway_ipaddr=::
+hfi_list[0]->tcp_info.route_metric=0
+hfi_list[0]->tcp_info.primary_dns_ipaddr=::
+hfi_list[0]->tcp_info.secondary_dns_ipaddr=::
+hfi_list[0]->tcp_info.dhcp_server_ipaddr=
+hfi_list[0]->tcp_info.host_name=nvmepoc-sles15-sp5
+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=fd09:9a46:b5c1:1fe::13f
+subsystem_ns_list[0]->trsvcid=4420
+subsystem_ns_list[0]->subsys_port_id=0
+subsystem_ns_list[0]->nsid=1
+subsystem_ns_list[0]->nid_type=3
+subsystem_ns_list[0]->nid=aab2c3c8444c47c599f23632e6364528
+subsystem_ns_list[0]->subsys_nqn=nqn.2022-12.de.suse.mwilck:zeus.vagrant-nvmet.subsys04
+subsystem_ns_list[0]->pdu_header_digest_required=0
+subsystem_ns_list[0]->data_digest_required=0
+subsystem_ns_list[0]->controller_id=9
+subsystem_ns_list[0]->asqsz=0
+subsystem_ns_list[0]->dhcp_root_path_string=(null)
diff --git a/test/nbft/gen-nbft-diffs.sh.in b/test/nbft/gen-nbft-diffs.sh.in
new file mode 100755
index 0000000..8b0b982
--- /dev/null
+++ b/test/nbft/gen-nbft-diffs.sh.in
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+for T in "@TABLES_DIR@"/*; do
+ "@NBFT_DUMP_PATH@" "$T" > "@DIFF_DIR@/`basename $T`"
+done
diff --git a/test/nbft/meson.build b/test/nbft/meson.build
new file mode 100644
index 0000000..919bf83
--- /dev/null
+++ b/test/nbft/meson.build
@@ -0,0 +1,85 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+#
+# This file is part of libnvme.
+# Copyright (c) 2023 Red Hat Inc.
+#
+# Authors: Tomas Bzatek <tbzatek@redhat.com>
+
+# NBFT parser tests over supplied NBFT ACPI table dumps
+
+tables_dir = 'tables'
+tables_bad_dir = 'tables_bad'
+diff_dir = 'diffs'
+
+tables = [
+ 'NBFT-auto-ipv6',
+ 'NBFT-dhcp-ipv6',
+ 'NBFT-rhpoc',
+ 'NBFT-static-ipv4',
+ 'NBFT-static-ipv4-discovery',
+ 'NBFT-static-ipv6',
+ 'NBFT-Dell.PowerEdge.R760',
+ 'NBFT-Dell.PowerEdge.R660-fw1.5.5-single'
+]
+
+tables_bad = [
+ 'NBFT-bad-oldspec',
+ 'NBFT-random-noise',
+]
+
+nbft_dump = executable(
+ 'nbft-dump',
+ ['nbft-dump.c'],
+ dependencies: libnvme_dep,
+ include_directories: [incdir, internal_incdir]
+)
+
+
+helper_data = configuration_data()
+helper_data.set('NBFT_DUMP_PATH', nbft_dump.full_path())
+helper_data.set('TABLES_DIR', meson.current_source_dir()/tables_dir)
+helper_data.set('DIFF_DIR', meson.current_source_dir()/diff_dir)
+
+dump_helper = configure_file(
+ input: 'nbft-dump-diff.sh.in',
+ output: '@BASENAME@',
+ configuration: helper_data
+)
+
+gen_diffs_helper = configure_file(
+ input: 'gen-nbft-diffs.sh.in',
+ output: '@BASENAME@',
+ configuration: helper_data
+)
+
+
+run_target(
+ 'nbft-diffs',
+ depends: nbft_dump,
+ command: [gen_diffs_helper]
+)
+
+
+diffcmd = find_program(
+ 'diff',
+ required: false
+)
+if diffcmd.found()
+ foreach table: tables
+ test(
+ table,
+ dump_helper,
+ args: [files(tables_dir/table),
+ files(diff_dir/table)]
+ )
+ endforeach
+endif
+
+foreach table: tables_bad
+ test(
+ table,
+ nbft_dump,
+ args: [files(tables_bad_dir/table)],
+ should_fail: true
+ )
+endforeach
diff --git a/test/nbft/nbft-dump-diff.sh.in b/test/nbft/nbft-dump-diff.sh.in
new file mode 100755
index 0000000..f697bce
--- /dev/null
+++ b/test/nbft/nbft-dump-diff.sh.in
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+if [ $# -ne 2 ]; then
+ echo "Usage: $0 TABLE DIFF" >&2
+ exit 255
+fi
+
+"@NBFT_DUMP_PATH@" "$1" | diff --unified "$2" -
diff --git a/test/nbft/nbft-dump.c b/test/nbft/nbft-dump.c
new file mode 100644
index 0000000..3ff5efa
--- /dev/null
+++ b/test/nbft/nbft-dump.c
@@ -0,0 +1,121 @@
+// SPDX-License-Identifier: LGPL-2.1-or-later
+/**
+ * This file is part of libnvme.
+ * Copyright (c) 2023 Red Hat Inc.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <inttypes.h>
+#include "libnvme.h"
+
+static void print_hex(unsigned char *buf, int len)
+{
+ int i;
+
+ for (i = 0; i < len; i++, buf++)
+ printf("%x", *buf);
+}
+
+static void print_nbft(struct nbft_info *table)
+{
+ unsigned int i, j;
+ struct nbft_info_hfi **hfi;
+ struct nbft_info_security **sec;
+ struct nbft_info_discovery **disc;
+ struct nbft_info_subsystem_ns **ssns;
+
+ printf("raw_nbft_size=%zd\n", table->raw_nbft_size);
+
+ printf("host.id=");
+ print_hex(table->host.id, NVME_UUID_LEN);
+ printf("\n");
+ printf("host.nqn=%s\n", table->host.nqn);
+ printf("host.host_id_configured=%d\n", table->host.host_id_configured);
+ printf("host.host_nqn_configured=%d\n", table->host.host_nqn_configured);
+ printf("host.primary=%d\n", table->host.primary);
+
+ for (hfi = table->hfi_list, i = 0; hfi && *hfi; hfi++, i++) {
+ printf("hfi_list[%u]->index=%d\n", i, (*hfi)->index);
+ printf("hfi_list[%u]->transport=%.*s\n", i, (int)sizeof((*hfi)->transport), (*hfi)->transport);
+ printf("hfi_list[%u]->tcp_info.pci_sbdf=%"PRIu32"\n", i, (*hfi)->tcp_info.pci_sbdf);
+ printf("hfi_list[%u]->tcp_info.mac_addr=", i);
+ print_hex((*hfi)->tcp_info.mac_addr, sizeof((*hfi)->tcp_info.mac_addr));
+ printf("\n");
+ printf("hfi_list[%u]->tcp_info.vlan=%"PRIu16"\n", i, (*hfi)->tcp_info.vlan);
+ printf("hfi_list[%u]->tcp_info.ip_origin=%u\n", i, (*hfi)->tcp_info.ip_origin);
+ printf("hfi_list[%u]->tcp_info.ipaddr=%s\n", i, (*hfi)->tcp_info.ipaddr);
+ printf("hfi_list[%u]->tcp_info.subnet_mask_prefix=%u\n", i, (*hfi)->tcp_info.subnet_mask_prefix);
+ printf("hfi_list[%u]->tcp_info.gateway_ipaddr=%s\n", i, (*hfi)->tcp_info.gateway_ipaddr);
+ printf("hfi_list[%u]->tcp_info.route_metric=%"PRIu16"\n", i, (*hfi)->tcp_info.route_metric);
+ printf("hfi_list[%u]->tcp_info.primary_dns_ipaddr=%s\n", i, (*hfi)->tcp_info.primary_dns_ipaddr);
+ printf("hfi_list[%u]->tcp_info.secondary_dns_ipaddr=%s\n", i, (*hfi)->tcp_info.secondary_dns_ipaddr);
+ printf("hfi_list[%u]->tcp_info.dhcp_server_ipaddr=%s\n", i, (*hfi)->tcp_info.dhcp_server_ipaddr);
+ printf("hfi_list[%u]->tcp_info.host_name=%s\n", i, (*hfi)->tcp_info.host_name);
+ printf("hfi_list[%u]->tcp_info.this_hfi_is_default_route=%d\n", i, (*hfi)->tcp_info.this_hfi_is_default_route);
+ printf("hfi_list[%u]->tcp_info.dhcp_override=%d\n", i, (*hfi)->tcp_info.dhcp_override);
+ }
+
+ for (sec = table->security_list, i = 0; sec && *sec; sec++, i++) {
+ printf("security_list[%u]->index=%d\n", i, (*sec)->index);
+ }
+
+ for (disc = table->discovery_list, i = 0; disc && *disc; disc++, i++) {
+ printf("discovery_list[%u]->index=%d\n", i, (*disc)->index);
+ if ((*disc)->security)
+ printf("discovery_list[%u]->security->index=%d\n", i, (*disc)->security->index);
+ if ((*disc)->hfi)
+ printf("discovery_list[%u]->hfi->index=%d\n", i, (*disc)->hfi->index);
+ printf("discovery_list[%u]->uri=%s\n", i, (*disc)->uri);
+ printf("discovery_list[%u]->nqn=%s\n", i, (*disc)->nqn);
+ }
+
+ for (ssns = table->subsystem_ns_list, i = 0; ssns && *ssns; ssns++, i++) {
+ printf("subsystem_ns_list[%u]->index=%d\n", i, (*ssns)->index);
+ if ((*ssns)->discovery)
+ printf("subsystem_ns_list[%u]->discovery->index=%d\n", i, (*ssns)->discovery->index);
+ if ((*ssns)->security)
+ printf("subsystem_ns_list[%u]->security->index=%d\n", i, (*ssns)->security->index);
+ printf("subsystem_ns_list[%u]->num_hfis=%d\n", i, (*ssns)->num_hfis);
+ for (hfi = (*ssns)->hfis, j = 0; hfi && *hfi; hfi++, j++)
+ printf("subsystem_ns_list[%u]->hfis[%u]->index=%d\n", i, j, (*hfi)->index);
+ printf("subsystem_ns_list[%u]->transport=%s\n", i, (*ssns)->transport);
+ printf("subsystem_ns_list[%u]->traddr=%s\n", i, (*ssns)->traddr);
+ printf("subsystem_ns_list[%u]->trsvcid=%s\n", i, (*ssns)->trsvcid);
+ printf("subsystem_ns_list[%u]->subsys_port_id=%"PRIu16"\n", i, (*ssns)->subsys_port_id);
+ printf("subsystem_ns_list[%u]->nsid=%"PRIu32"\n", i, (*ssns)->nsid);
+ printf("subsystem_ns_list[%u]->nid_type=%d\n", i, (*ssns)->nid_type);
+ printf("subsystem_ns_list[%u]->nid=", i);
+ print_hex((*ssns)->nid, 16);
+ printf("\n");
+ printf("subsystem_ns_list[%u]->subsys_nqn=%s\n", i, (*ssns)->subsys_nqn);
+ printf("subsystem_ns_list[%u]->pdu_header_digest_required=%d\n", i, (*ssns)->pdu_header_digest_required);
+ printf("subsystem_ns_list[%u]->data_digest_required=%d\n", i, (*ssns)->data_digest_required);
+ printf("subsystem_ns_list[%u]->controller_id=%d\n", i, (*ssns)->controller_id);
+ printf("subsystem_ns_list[%u]->asqsz=%d\n", i, (*ssns)->asqsz);
+ printf("subsystem_ns_list[%u]->dhcp_root_path_string=%s\n", i, (*ssns)->dhcp_root_path_string);
+ }
+}
+
+int main(int argc, char **argv)
+{
+ struct nbft_info *table = NULL;
+
+ if (argc < 2) {
+ fprintf(stderr, "Usage: %s TABLE\n", argv[0]);
+ return 1;
+ }
+
+ if (nvme_nbft_read(&table, argv[1]) != 0) {
+ fprintf(stderr, "Error parsing the NBFT table %s: %m\n",
+ argv[1]);
+ return 2;
+ }
+
+ print_nbft(table);
+
+ nvme_nbft_free(table);
+ return 0;
+}
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/nbft/tables/NBFT-auto-ipv6 b/test/nbft/tables/NBFT-auto-ipv6
new file mode 100644
index 0000000..64457d7
--- /dev/null
+++ b/test/nbft/tables/NBFT-auto-ipv6
Binary files differ
diff --git a/test/nbft/tables/NBFT-dhcp-ipv4 b/test/nbft/tables/NBFT-dhcp-ipv4
new file mode 100644
index 0000000..1af159d
--- /dev/null
+++ b/test/nbft/tables/NBFT-dhcp-ipv4
Binary files differ
diff --git a/test/nbft/tables/NBFT-dhcp-ipv6 b/test/nbft/tables/NBFT-dhcp-ipv6
new file mode 100644
index 0000000..20715ee
--- /dev/null
+++ b/test/nbft/tables/NBFT-dhcp-ipv6
Binary files differ
diff --git a/test/nbft/tables/NBFT-rhpoc b/test/nbft/tables/NBFT-rhpoc
new file mode 100644
index 0000000..5d0a6cc
--- /dev/null
+++ b/test/nbft/tables/NBFT-rhpoc
Binary files differ
diff --git a/test/nbft/tables/NBFT-static-ipv4 b/test/nbft/tables/NBFT-static-ipv4
new file mode 100644
index 0000000..bf3f840
--- /dev/null
+++ b/test/nbft/tables/NBFT-static-ipv4
Binary files differ
diff --git a/test/nbft/tables/NBFT-static-ipv4-discovery b/test/nbft/tables/NBFT-static-ipv4-discovery
new file mode 100644
index 0000000..7ebb40e
--- /dev/null
+++ b/test/nbft/tables/NBFT-static-ipv4-discovery
Binary files differ
diff --git a/test/nbft/tables/NBFT-static-ipv6 b/test/nbft/tables/NBFT-static-ipv6
new file mode 100644
index 0000000..07b09cf
--- /dev/null
+++ b/test/nbft/tables/NBFT-static-ipv6
Binary files differ
diff --git a/test/nbft/tables_bad/NBFT-bad-oldspec b/test/nbft/tables_bad/NBFT-bad-oldspec
new file mode 100644
index 0000000..e09d6ad
--- /dev/null
+++ b/test/nbft/tables_bad/NBFT-bad-oldspec
Binary files differ
diff --git a/test/nbft/tables_bad/NBFT-random-noise b/test/nbft/tables_bad/NBFT-random-noise
new file mode 100644
index 0000000..296bcfe
--- /dev/null
+++ b/test/nbft/tables_bad/NBFT-random-noise
Binary files differ