ostree: fix ptests

1. Fix tests that output colored text but try to verify uncolored text - filter the
   output through "tee" to remove coloring.
2. Add missing dependency
3. Fix a test that fails when C.utf-8 locale is not available on the machine (patch submitted upstream)
4. Enable network connection by setting a nameserver in resolv.conf

While execution is possible, it still requires both ostree and busybox to be compiled statically.

Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
This commit is contained in:
Gyorgy Sarvari
2025-10-30 21:06:07 +01:00
parent ea936b8f0e
commit 01b7c42dfd
3 changed files with 116 additions and 1 deletions
@@ -1,3 +1,14 @@
#! /bin/sh
gnome-desktop-testing-runner libostree
if ! nslookup openpgpkey.test.com; then
mv /etc/resolv.conf /etc/resolv.conf.bak
echo "nameserver 8.8.8.8" > /etc/resolv.conf
trap "mv /etc/resolv.conf.bak /etc/resolv.conf" INT EXIT
fi
# The tests use terminal colors when the output is a tty. This is a problem, because the tests
# check the output of some commands, which might be colored - and the regex used for matching does not
# account for the colors. This seemingly useless tee is here to get rid of the colors. (The application
# doesn't respect the NO_COLOR envvar and doesn't seem to have other options to disable coloring)
gnome-desktop-testing-runner libostree | tee
@@ -0,0 +1,102 @@
From 9060221fa24ee2d53de416ee4fa15dd5d3668123 Mon Sep 17 00:00:00 2001
From: Gyorgy Sarvari <skandigraun@gmail.com>
Date: Thu, 30 Oct 2025 13:43:20 +0100
Subject: [PATCH] tests: account for different locales in remote-gpg-list-keys
test
During test preparation in libtest-core.sh either C or en_US locale
is set for the test execution.
The remote-gpg-list-keys compares outputs that contain locale-dependent
dates, but the current test case expects the result to be in C locale.
However in case C.utf-8 locale is not available, but en_US.utf-8 locale
is available, then the latter will be used, and the testcase will fail,
because it expects dates to be in this format:
Tue 17 Mar 2015 02:00:32 PM UTC
However with US locale it receives the date like this:
Tue Mar 17 2015 02:00:32 PM UTC
This change converts these dates to the current locale before comparing
the expected gpg key content with the received one.
Upstream-Status: Submitted [https://github.com/ostreedev/ostree/pull/3545/commits/9060221fa24ee2d53de416ee4fa15dd5d3668123]
Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
---
tests/test-remote-gpg-list-keys.sh | 32 ++++++++++++++++++++----------
1 file changed, 22 insertions(+), 10 deletions(-)
diff --git a/tests/test-remote-gpg-list-keys.sh b/tests/test-remote-gpg-list-keys.sh
index de24bf4da2..a697ecce54 100755
--- a/tests/test-remote-gpg-list-keys.sh
+++ b/tests/test-remote-gpg-list-keys.sh
@@ -61,14 +61,19 @@ echo "ok remote with global keyring"
# Import a key and check that it's listed
${OSTREE} remote gpg-import --keyring ${TEST_GPG_KEYHOME}/key1.asc R1
${OSTREE} remote gpg-list-keys R1 > result
-cat > expected <<"EOF"
+
+# In different locales the date is returned differently
+# Convert the known Creation date to the current locale.
+EXPECTED_DATE=$(date -d "Tue Sep 10 02:29:42 2013" "+%c")
+
+cat > expected <<EOF
Key: 5E65DE75AB1C501862D476347FCA23D8472CDAFA
- Created: Tue Sep 10 02:29:42 2013
+ Created: $EXPECTED_DATE
UID: Ostree Tester <test@test.com>
Advanced update URL: https://openpgpkey.test.com/.well-known/openpgpkey/test.com/hu/iffe93qcsgp4c8ncbb378rxjo6cn9q6u?l=test
Direct update URL: https://test.com/.well-known/openpgpkey/hu/iffe93qcsgp4c8ncbb378rxjo6cn9q6u?l=test
Subkey: CC47B2DFB520AEF231180725DF20F58B408DEA49
- Created: Tue Sep 10 02:29:42 2013
+ Created: $EXPECTED_DATE
EOF
assert_files_equal result expected
@@ -85,28 +90,35 @@ echo "ok global no keyring"
OSTREE_GPG_HOME=${trusteddir}
${OSTREE} remote gpg-list-keys > result
OSTREE_GPG_HOME=${emptydir}
-cat > expected <<"EOF"
+
+# In different locales the date is returned differently
+# Convert the known Creation date to the current locale.
+EXPECTED_DATE=$(date -d "Tue Sep 10 02:29:42 2013" "+%c")
+EXPECTED_DATE2=$(date -d "Tue Mar 17 14:00:32 2015" "+%c")
+EXPECTED_DATE3=$(date -d "Tue Mar 17 14:01:05 2015" "+%c")
+
+cat > expected <<EOF
Key: 5E65DE75AB1C501862D476347FCA23D8472CDAFA
- Created: Tue Sep 10 02:29:42 2013
+ Created: $EXPECTED_DATE
UID: Ostree Tester <test@test.com>
Advanced update URL: https://openpgpkey.test.com/.well-known/openpgpkey/test.com/hu/iffe93qcsgp4c8ncbb378rxjo6cn9q6u?l=test
Direct update URL: https://test.com/.well-known/openpgpkey/hu/iffe93qcsgp4c8ncbb378rxjo6cn9q6u?l=test
Subkey: CC47B2DFB520AEF231180725DF20F58B408DEA49
- Created: Tue Sep 10 02:29:42 2013
+ Created: $EXPECTED_DATE
Key: 7B3B1020D74479687FDB2273D8228CFECA950D41
- Created: Tue Mar 17 14:00:32 2015
+ Created: $EXPECTED_DATE2
UID: Ostree Tester II <test2@test.com>
Advanced update URL: https://openpgpkey.test.com/.well-known/openpgpkey/test.com/hu/nnxwsxno46ap6hw7fgphp68j76egpfa9?l=test2
Direct update URL: https://test.com/.well-known/openpgpkey/hu/nnxwsxno46ap6hw7fgphp68j76egpfa9?l=test2
Subkey: 1EFA95C06EB1EB91754575E004B69C2560D53993
- Created: Tue Mar 17 14:00:32 2015
+ Created: $EXPECTED_DATE2
Key: 7D29CF060B8269CDF63BFBDD0D15FAE7DF444D67
- Created: Tue Mar 17 14:01:05 2015
+ Created: $EXPECTED_DATE3
UID: Ostree Tester III <test3@test.com>
Advanced update URL: https://openpgpkey.test.com/.well-known/openpgpkey/test.com/hu/8494gyqhmrcs6gn38tn6kgjexet117cj?l=test3
Direct update URL: https://test.com/.well-known/openpgpkey/hu/8494gyqhmrcs6gn38tn6kgjexet117cj?l=test3
Subkey: 0E45E48CBF7B360C0E04443E0C601A7402416340
- Created: Tue Mar 17 14:01:05 2015
+ Created: $EXPECTED_DATE3
EOF
assert_files_equal result expected
@@ -19,6 +19,7 @@ DEPENDS = " \
SRC_URI = " \
gitsm://github.com/ostreedev/ostree;branch=main;protocol=https \
file://tests-account-for-different-locales-in-remote-gpg-list-keys-test.patch \
file://run-ptest \
"
SRCREV = "f1155c8d283c3c85d74d5e1050b0dcf8198f750a"
@@ -196,6 +197,7 @@ RDEPENDS:${PN}-ptest += " \
util-linux \
xz \
${PN}-trivial-httpd \
${PN}-switchroot \
python3-pyyaml \
${@bb.utils.contains('PACKAGECONFIG', 'gjs', 'gjs', '', d)} \
"