[Pdbg] [PATCH v2 6/6] tests: Add attribute api tests

Amitay Isaacs amitay at ozlabs.org
Thu Apr 2 09:55:26 AEDT 2020


Signed-off-by: Amitay Isaacs <amitay at ozlabs.org>
---
 Makefile.am               |   2 +
 tests/test_attr_array.sh  | 133 ++++++++++++++++++++++++++++++++++++++
 tests/test_attr_packed.sh |  82 +++++++++++++++++++++++
 3 files changed, 217 insertions(+)
 create mode 100755 tests/test_attr_array.sh
 create mode 100755 tests/test_attr_packed.sh

diff --git a/Makefile.am b/Makefile.am
index 84e1a1d..3c37ac8 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -28,6 +28,8 @@ PDBG_TESTS = \
 	tests/test_tree.sh		\
 	tests/test_tree2.sh		\
 	tests/test_prop.sh		\
+	tests/test_attr_array.sh	\
+	tests/test_attr_packed.sh	\
 	tests/test_p9_fapi_translation.sh
 
 TESTS = $(libpdbg_tests) optcmd_test $(PDBG_TESTS)
diff --git a/tests/test_attr_array.sh b/tests/test_attr_array.sh
new file mode 100755
index 0000000..768e22d
--- /dev/null
+++ b/tests/test_attr_array.sh
@@ -0,0 +1,133 @@
+#!/bin/sh
+
+. $(dirname "$0")/driver.sh
+
+FAKE_DTB=fake.dtb
+TEST_DTB=fake-attr.dtb
+
+export PDBG_DTB=$TEST_DTB
+
+test_setup cp $FAKE_DTB $TEST_DTB
+test_cleanup rm -f $TEST_DTB
+
+test_group "libpdbg array attribute tests"
+
+test_result 0 <<EOF
+0x00 
+EOF
+test_run libpdbg_attr_test / read ATTR1 array 1 1
+
+for size in 2 4 8 ; do
+	test_result 88 --
+	test_run libpdbg_attr_test / read ATTR1 array $size 1
+done
+
+test_result 0 <<EOF
+0x0000 
+EOF
+test_run libpdbg_attr_test / read ATTR2 array 2 1
+
+for size in 1 4 8 ; do
+	test_result 88 --
+	test_run libpdbg_attr_test / read ATTR2 array $size 1
+done
+
+test_result 0 <<EOF
+0x00000000 
+EOF
+test_run libpdbg_attr_test / read ATTR4 array 4 1
+
+for size in 1 2 8 ; do
+	test_result 88 --
+	test_run libpdbg_attr_test / read ATTR4 array $size 1
+done
+
+test_result 0 <<EOF
+0x0000000000000000 
+EOF
+test_run libpdbg_attr_test / read ATTR8 array 8 1
+
+for size in 1 2 4 ; do
+	test_result 88 --
+	test_run libpdbg_attr_test / read ATTR8 array $size 1
+done
+
+test_result 0 --
+test_run libpdbg_attr_test / write ATTR1 array 1 1 0x11
+
+test_result 0 <<EOF
+0x11 
+EOF
+test_run libpdbg_attr_test / read ATTR1 array 1 1
+
+test_result 0 --
+test_run libpdbg_attr_test / write ATTR2 array 1 2 0x11 0x22
+
+test_result 0 <<EOF
+0x11 0x22 
+EOF
+test_run libpdbg_attr_test / read ATTR2 array 1 2
+
+test_result 0 --
+test_run libpdbg_attr_test / write ATTR2 array 2 1 0x1212
+
+test_result 0 <<EOF
+0x1212 
+EOF
+test_run libpdbg_attr_test / read ATTR2 array 2 1
+
+test_result 0 --
+test_run libpdbg_attr_test / write ATTR4 array 1 4 0x11 0x22 0x33 0x44
+
+test_result 0 <<EOF
+0x11 0x22 0x33 0x44 
+EOF
+test_run libpdbg_attr_test / read ATTR4 array 1 4
+
+test_result 0 --
+test_run libpdbg_attr_test / write ATTR4 array 2 2 0x1234 0x1234
+
+test_result 0 <<EOF
+0x1234 0x1234 
+EOF
+test_run libpdbg_attr_test / read ATTR4 array 2 2
+
+test_result 0 --
+test_run libpdbg_attr_test / write ATTR4 array 4 1 0x12345678
+
+test_result 0 <<EOF
+0x12345678 
+EOF
+test_run libpdbg_attr_test / read ATTR4 array 4 1
+
+test_result 0 --
+test_run libpdbg_attr_test / write ATTR8 array 1 8 0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88
+
+test_result 0 <<EOF
+0x11 0x22 0x33 0x44 0x55 0x66 0x77 0x88 
+EOF
+test_run libpdbg_attr_test / read ATTR8 array 1 8
+
+test_result 0 --
+test_run libpdbg_attr_test / write ATTR8 array 2 4 0x1234 0x1234 0x1234 0x5678
+
+test_result 0 <<EOF
+0x1234 0x1234 0x1234 0x5678 
+EOF
+test_run libpdbg_attr_test / read ATTR8 array 2 4
+
+test_result 0 --
+test_run libpdbg_attr_test / write ATTR8 array 4 2 0x12345678 0x23456789
+
+test_result 0 <<EOF
+0x12345678 0x23456789 
+EOF
+test_run libpdbg_attr_test / read ATTR8 array 4 2
+
+test_result 0 --
+test_run libpdbg_attr_test / write ATTR8 array 8 1 0x1234567890abcdef
+
+test_result 0 <<EOF
+0x1234567890abcdef 
+EOF
+test_run libpdbg_attr_test / read ATTR8 array 8 1
diff --git a/tests/test_attr_packed.sh b/tests/test_attr_packed.sh
new file mode 100755
index 0000000..36606bc
--- /dev/null
+++ b/tests/test_attr_packed.sh
@@ -0,0 +1,82 @@
+#!/bin/sh
+
+. $(dirname "$0")/driver.sh
+
+FAKE_DTB=fake.dtb
+TEST_DTB=fake-attr.dtb
+
+export PDBG_DTB=$TEST_DTB
+
+test_setup cp $FAKE_DTB $TEST_DTB
+test_cleanup rm -f $TEST_DTB
+
+test_group "libpdbg packed attribute tests"
+
+for size in 1 2 4 8 ; do
+	test_result 88 --
+	test_run libpdbg_attr_test / read ATTR16 packed $size
+done
+
+test_result 0 --
+test_run libpdbg_attr_test / write ATTR16 packed 4444 0x1111 0x2222 0x3333 0x4444
+
+test_result 0 <<EOF
+0x00001111 0x00002222 0x00003333 0x00004444 
+EOF
+test_run libpdbg_attr_test / read ATTR16 packed 4444
+
+test_result 0 --
+test_run libpdbg_attr_test / write ATTR16 packed 88 0x12345678 0x23456789
+
+test_result 0 <<EOF
+0x0000000012345678 0x0000000023456789 
+EOF
+test_run libpdbg_attr_test / read ATTR16 packed 88
+
+test_result 0 --
+test_run libpdbg_attr_test / write ATTR16 packed 844 0x11111111 0x22222222 0x33333333
+
+test_result 0 <<EOF
+0x0000000011111111 0x22222222 0x33333333 
+EOF
+test_run libpdbg_attr_test / read ATTR16 packed 844
+
+test_result 0 --
+test_run libpdbg_attr_test / write ATTR16 packed 8422 0x11111111 0x22222222 0x3333 0x4444
+
+test_result 0 <<EOF
+0x0000000011111111 0x22222222 0x3333 0x4444 
+EOF
+test_run libpdbg_attr_test / read ATTR16 packed 8422
+
+test_result 0 --
+test_run libpdbg_attr_test / write ATTR16 packed 12481 0x11 0x22 0x33 0x44 0x55
+
+test_result 0 <<EOF
+0x11 0x0022 0x00000033 0x0000000000000044 0x55 
+EOF
+test_run libpdbg_attr_test / read ATTR16 packed 12481
+
+test_result 0 --
+test_run libpdbg_attr_test / write ATTR16 packed 88 0x1122334455667788 0x9900aabbccddeeff
+
+test_result 0 <<EOF
+0x1122334455667788 0x9900aabbccddeeff 
+EOF
+test_run libpdbg_attr_test / read ATTR16 packed 88
+
+test_result 0 <<EOF
+0x11223344 0x55667788 0x9900aabb 0xccddeeff 
+EOF
+test_run libpdbg_attr_test / read ATTR16 packed 4444
+
+test_result 0 <<EOF
+0x1122 0x3344 0x5566 0x7788 0x9900 0xaabb 0xccdd 0xeeff 
+EOF
+test_run libpdbg_attr_test / read ATTR16 packed 22222222
+
+test_result 0 <<EOF
+0x1122 0x3344556677889900 0xaabbccdd 0xeeff 
+EOF
+test_run libpdbg_attr_test / read ATTR16 packed 2842
+
-- 
2.25.1



More information about the Pdbg mailing list