From 768eb1fa565353fbb6aab2107d9cd7861b638d93 Mon Sep 17 00:00:00 2001 From: Michael Olbrich Date: Thu, 4 Jul 2024 15:12:25 +0200 Subject: [PATCH] test: handle more rauc versions Signed-off-by: Michael Olbrich --- Makefile.am | 12 +++++--- test/misc.test | 30 ++++++++++++------- test/{test.raucb.info => test.raucb.info.1} | 0 ...{test.raucb.info.new => test.raucb.info.2} | 0 test/test.raucb.info.3 | 27 +++++++++++++++++ test/test.raucb.info.4 | 27 +++++++++++++++++ test/{test2.raucb.info => test2.raucb.info.1} | 0 ...est2.raucb.info.new => test2.raucb.info.2} | 0 test/test2.raucb.info.3 | 27 +++++++++++++++++ test/test2.raucb.info.4 | 27 +++++++++++++++++ 10 files changed, 136 insertions(+), 14 deletions(-) rename test/{test.raucb.info => test.raucb.info.1} (100%) rename test/{test.raucb.info.new => test.raucb.info.2} (100%) create mode 100644 test/test.raucb.info.3 create mode 100644 test/test.raucb.info.4 rename test/{test2.raucb.info => test2.raucb.info.1} (100%) rename test/{test2.raucb.info.new => test2.raucb.info.2} (100%) create mode 100644 test/test2.raucb.info.3 create mode 100644 test/test2.raucb.info.4 diff --git a/Makefile.am b/Makefile.am index 8f70190..1aac4f1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -143,10 +143,14 @@ EXTRA_DIST += \ test/sparse.config \ test/squashfs.config \ test/tar.config \ - test/test.raucb.info \ - test/test.raucb.info.new \ - test/test2.raucb.info \ - test/test2.raucb.info.new \ + test/test.raucb.info.1 \ + test/test.raucb.info.2 \ + test/test.raucb.info.3 \ + test/test.raucb.info.4 \ + test/test2.raucb.info.1 \ + test/test2.raucb.info.2 \ + test/test2.raucb.info.3 \ + test/test2.raucb.info.4 \ test/ubi.config \ test/ubifs.config \ test/vfat.config diff --git a/test/misc.test b/test/misc.test index d4e59b6..0b4396f 100755 --- a/test/misc.test +++ b/test/misc.test @@ -34,8 +34,26 @@ setup_rauc() { echo "xtest2" > input/rauc2.content } +version_lt() { + first="$(printf "${1}\n${2}" | sort -V | head -n1)" + test "${first}" == "${1}" && test "${1}" != "${2}" +} + +rauc_cmp() { + if version_lt "${rauc_version}" "1.6"; then + test_cmp "${testdir}/${1}.raucb.info.1" "${1}.raucb.info" + elif version_lt "${rauc_version}" "1.9"; then + test_cmp "${testdir}/${1}.raucb.info.2" "${1}.raucb.info" + elif version_lt "${rauc_version}" "1.10"; then + test_cmp "${testdir}/${1}.raucb.info.3" "${1}.raucb.info" + else + test_cmp "${testdir}/${1}.raucb.info.4" "${1}.raucb.info" + fi +} + exec_test_set_prereq rauc test_expect_success rauc "rauc" " + rauc_version="$(rauc --version | sed 's/rauc //')" setup_rauc && run_genimage rauc.config test.raucb && rauc info \ @@ -45,11 +63,7 @@ test_expect_success rauc "rauc" " | sed -e 's;O = Test Org, CN = ;/O=Test Org/CN=;' \ -e '/Bundle Format:[ \t]*plain$/d' \ > test.raucb.info && - if ! grep -r 'Filename:' test.raucb.info; then - test_cmp '${testdir}/test.raucb.info' test.raucb.info - else - test_cmp '${testdir}/test.raucb.info.new' test.raucb.info - fi + rauc_cmp test rauc info \ --keyring input/rauc-openssl-ca/ca.cert.pem \ --cert input/rauc-openssl-ca/ca.cert.pem \ @@ -57,11 +71,7 @@ test_expect_success rauc "rauc" " | sed -e 's;O = Test Org, CN = ;/O=Test Org/CN=;' \ -e '/Bundle Format:[ \t]*plain$/d' \ > test2.raucb.info && - if ! grep -r 'Filename:' test2.raucb.info; then - test_cmp '${testdir}/test2.raucb.info' test2.raucb.info - else - test_cmp '${testdir}/test2.raucb.info.new' test2.raucb.info - fi + rauc_cmp test2 " exec_test_set_prereq simg2img diff --git a/test/test.raucb.info b/test/test.raucb.info.1 similarity index 100% rename from test/test.raucb.info rename to test/test.raucb.info.1 diff --git a/test/test.raucb.info.new b/test/test.raucb.info.2 similarity index 100% rename from test/test.raucb.info.new rename to test/test.raucb.info.2 diff --git a/test/test.raucb.info.3 b/test/test.raucb.info.3 new file mode 100644 index 0000000..664e82f --- /dev/null +++ b/test/test.raucb.info.3 @@ -0,0 +1,27 @@ +Compatible: 'genimage-test' +Version: '42' +Description: ''genimage rauc test'' +Build: '23' +Hooks: '' +Manifest Hash: '396427d8c699c8c1f1c89836dc9883448d1b176477848fff63cdd1bdae1cd1a0' + + +1 Image: + [rootfs] + Filename: content + Checksum: f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2 + Size: 5 + Hooks: + +Certificate Chain: + 0 Subject: /O=Test Org/CN=Test Org Development-1 + Issuer: /O=Test Org/CN=Test Org rauc CA Development + SPKI sha256: 79:82:8B:11:2C:F2:78:06:60:4D:09:3B:55:3D:AF:D8:B4:B1:02:9A:D3:AC:40:57:77:1D:D0:AF:E8:B9:9E:90 + Not Before: Jan 1 00:00:00 1970 GMT + Not After: Dec 31 23:59:59 9999 GMT + 1 Subject: /O=Test Org/CN=Test Org rauc CA Development + Issuer: /O=Test Org/CN=Test Org rauc CA Development + SPKI sha256: 09:72:43:C2:97:DA:BB:C6:39:FE:41:84:10:2C:69:9C:6E:8D:AD:06:2F:62:66:A5:CB:15:44:77:E5:DB:BE:AD + Not Before: Jan 1 00:00:00 1970 GMT + Not After: Dec 31 23:59:59 9999 GMT + diff --git a/test/test.raucb.info.4 b/test/test.raucb.info.4 new file mode 100644 index 0000000..3a38acb --- /dev/null +++ b/test/test.raucb.info.4 @@ -0,0 +1,27 @@ +Compatible: 'genimage-test' +Version: '42' +Description: ''genimage rauc test'' +Build: '23' +Hooks: '' +Manifest Hash: '396427d8c699c8c1f1c89836dc9883448d1b176477848fff63cdd1bdae1cd1a0' + + +1 Image: + [rootfs] + Filename: content + Checksum: f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2 + Size: 5 bytes + Hooks: + +Certificate Chain: + 0 Subject: /O=Test Org/CN=Test Org Development-1 + Issuer: /O=Test Org/CN=Test Org rauc CA Development + SPKI sha256: 79:82:8B:11:2C:F2:78:06:60:4D:09:3B:55:3D:AF:D8:B4:B1:02:9A:D3:AC:40:57:77:1D:D0:AF:E8:B9:9E:90 + Not Before: Jan 1 00:00:00 1970 GMT + Not After: Dec 31 23:59:59 9999 GMT + 1 Subject: /O=Test Org/CN=Test Org rauc CA Development + Issuer: /O=Test Org/CN=Test Org rauc CA Development + SPKI sha256: 09:72:43:C2:97:DA:BB:C6:39:FE:41:84:10:2C:69:9C:6E:8D:AD:06:2F:62:66:A5:CB:15:44:77:E5:DB:BE:AD + Not Before: Jan 1 00:00:00 1970 GMT + Not After: Dec 31 23:59:59 9999 GMT + diff --git a/test/test2.raucb.info b/test/test2.raucb.info.1 similarity index 100% rename from test/test2.raucb.info rename to test/test2.raucb.info.1 diff --git a/test/test2.raucb.info.new b/test/test2.raucb.info.2 similarity index 100% rename from test/test2.raucb.info.new rename to test/test2.raucb.info.2 diff --git a/test/test2.raucb.info.3 b/test/test2.raucb.info.3 new file mode 100644 index 0000000..582724e --- /dev/null +++ b/test/test2.raucb.info.3 @@ -0,0 +1,27 @@ +Compatible: 'genimage-test' +Version: '42' +Description: ''genimage rauc test'' +Build: '23' +Hooks: '' +Manifest Hash: 'ef0e93a54af2689a033ad524522c4b6b97115bad3ac0b907e01a41221f41e729' + + +1 Image: + [rootfs] + Filename: data + Checksum: 7d6fd7774f0d87624da6dcf16d0d3d104c3191e771fbe2f39c86aed4b2bf1a0f + Size: 6 + Hooks: + +Certificate Chain: + 0 Subject: /O=Test Org/CN=Test Org Development-1 + Issuer: /O=Test Org/CN=Test Org rauc CA Development + SPKI sha256: 79:82:8B:11:2C:F2:78:06:60:4D:09:3B:55:3D:AF:D8:B4:B1:02:9A:D3:AC:40:57:77:1D:D0:AF:E8:B9:9E:90 + Not Before: Jan 1 00:00:00 1970 GMT + Not After: Dec 31 23:59:59 9999 GMT + 1 Subject: /O=Test Org/CN=Test Org rauc CA Development + Issuer: /O=Test Org/CN=Test Org rauc CA Development + SPKI sha256: 09:72:43:C2:97:DA:BB:C6:39:FE:41:84:10:2C:69:9C:6E:8D:AD:06:2F:62:66:A5:CB:15:44:77:E5:DB:BE:AD + Not Before: Jan 1 00:00:00 1970 GMT + Not After: Dec 31 23:59:59 9999 GMT + diff --git a/test/test2.raucb.info.4 b/test/test2.raucb.info.4 new file mode 100644 index 0000000..b0bf0d3 --- /dev/null +++ b/test/test2.raucb.info.4 @@ -0,0 +1,27 @@ +Compatible: 'genimage-test' +Version: '42' +Description: ''genimage rauc test'' +Build: '23' +Hooks: '' +Manifest Hash: 'ef0e93a54af2689a033ad524522c4b6b97115bad3ac0b907e01a41221f41e729' + + +1 Image: + [rootfs] + Filename: data + Checksum: 7d6fd7774f0d87624da6dcf16d0d3d104c3191e771fbe2f39c86aed4b2bf1a0f + Size: 6 bytes + Hooks: + +Certificate Chain: + 0 Subject: /O=Test Org/CN=Test Org Development-1 + Issuer: /O=Test Org/CN=Test Org rauc CA Development + SPKI sha256: 79:82:8B:11:2C:F2:78:06:60:4D:09:3B:55:3D:AF:D8:B4:B1:02:9A:D3:AC:40:57:77:1D:D0:AF:E8:B9:9E:90 + Not Before: Jan 1 00:00:00 1970 GMT + Not After: Dec 31 23:59:59 9999 GMT + 1 Subject: /O=Test Org/CN=Test Org rauc CA Development + Issuer: /O=Test Org/CN=Test Org rauc CA Development + SPKI sha256: 09:72:43:C2:97:DA:BB:C6:39:FE:41:84:10:2C:69:9C:6E:8D:AD:06:2F:62:66:A5:CB:15:44:77:E5:DB:BE:AD + Not Before: Jan 1 00:00:00 1970 GMT + Not After: Dec 31 23:59:59 9999 GMT +