tests: Add test for NoRuntime extra-data app

This commit is contained in:
bbhtt
2026-04-10 10:14:23 +05:30
committed by Simon McVittie
parent c14ad37229
commit 79cb10e880
4 changed files with 77 additions and 6 deletions

View File

@@ -37,7 +37,7 @@ jobs:
libjson-glib-dev shared-mime-info desktop-file-utils libpolkit-agent-1-dev libpolkit-gobject-1-dev \
libseccomp-dev libcurl4-openssl-dev libsystemd-dev libxml2-utils libgpgme11-dev gobject-introspection \
libgirepository1.0-dev libappstream-dev libdconf-dev clang socat meson libdbus-1-dev e2fslibs-dev bubblewrap xdg-dbus-proxy \
meson ninja-build libyaml-dev libstemmer-dev gperf itstool libmalcontent-0-dev libxau-dev libgdk-pixbuf2.0-dev openssl
meson ninja-build libyaml-dev libstemmer-dev gperf itstool libmalcontent-0-dev libxau-dev libgdk-pixbuf2.0-dev openssl libc6-dev
# One of the tests wants this
sudo mkdir /tmp/flatpak-com.example.App-OwnedByRoot
- name: Check out flatpak
@@ -96,7 +96,7 @@ jobs:
libfuse-dev ostree libostree-dev libarchive-dev libzstd-dev libcap-dev libattr1-dev libdw-dev libelf-dev python3-pyparsing \
libjson-glib-dev shared-mime-info desktop-file-utils libpolkit-agent-1-dev libpolkit-gobject-1-dev \
libseccomp-dev libcurl4-openssl-dev libsystemd-dev libxml2-utils libgpgme11-dev gobject-introspection \
libgirepository1.0-dev libappstream-dev libdconf-dev clang socat meson libdbus-1-dev e2fslibs-dev
libgirepository1.0-dev libappstream-dev libdconf-dev clang socat meson libdbus-1-dev e2fslibs-dev libc6-dev
# One of the tests wants this
sudo mkdir /tmp/flatpak-com.example.App-OwnedByRoot
- name: Check out flatpak
@@ -169,7 +169,7 @@ jobs:
libjson-glib-dev shared-mime-info desktop-file-utils libpolkit-agent-1-dev libpolkit-gobject-1-dev \
libseccomp-dev libcurl4-openssl-dev libsystemd-dev libxml2-utils libgpgme11-dev gobject-introspection \
libgirepository1.0-dev libappstream-dev libdconf-dev clang e2fslibs-dev meson socat libxau-dev libgdk-pixbuf2.0-dev \
xmlto
xmlto libc6-dev
- name: Check out flatpak
uses: actions/checkout@v4
with:
@@ -212,7 +212,7 @@ jobs:
libjson-glib-dev shared-mime-info desktop-file-utils libpolkit-agent-1-dev libpolkit-gobject-1-dev \
libseccomp-dev libcurl4-openssl-dev libsystemd-dev libxml2-utils libgpgme11-dev gobject-introspection \
libgirepository1.0-dev libappstream-dev libdconf-dev clang socat meson libdbus-1-dev \
valgrind e2fslibs-dev meson libxau-dev libgdk-pixbuf2.0-dev
valgrind e2fslibs-dev meson libxau-dev libgdk-pixbuf2.0-dev libc6-dev
- name: Check out flatpak
uses: actions/checkout@v4
with:

View File

@@ -0,0 +1,15 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
static const char msg[] = "noruntime-extra-data\n";
int main(void) {
mkdir("/app/extra", 0755);
int fd = open("/app/extra/ran", O_WRONLY | O_CREAT | O_TRUNC, 0644);
if (fd < 0)
return 1;
write(fd, msg, sizeof(msg) - 1);
close(fd);
return 0;
}

View File

@@ -289,6 +289,21 @@ executable(
install_dir : installed_testdir,
)
if cc.links('#include <stdio.h>\nint main(void) { printf("test"); return 0; }',
args: ['-static'],
name: 'static libc')
executable(
'apply-extra-static',
'apply-extra-static.c',
install : get_option('installed_tests'),
install_dir : installed_testdir,
override_options : ['b_sanitize=none'],
link_args : ['-static'],
)
else
warning('static libc not available, apply-extra-static will be skipped')
endif
subdir('share/xdg-desktop-portal/portals')
subdir('services')
subdir('test-keyring')

View File

@@ -45,7 +45,7 @@ curl "${EXTRA_DATA_URL}" -o "${DOWNLOADED_EXTRA_DATA}"
EXTRA_DATA_SIZE=$(stat --printf="%s" "${DOWNLOADED_EXTRA_DATA}")
EXTRA_DATA_SHA256=$(sha256sum "${DOWNLOADED_EXTRA_DATA}" | cut -f1 -d' ')
echo "1..2"
echo "1..3"
# build the app with the extra data
EXTRA_DATA="--extra-data=test:${EXTRA_DATA_SHA256}:${EXTRA_DATA_SIZE}:${EXTRA_DATA_SIZE}:${EXTRA_DATA_URL}"
@@ -95,4 +95,45 @@ assert_file_has_content out "extra-data-test-content"
${FLATPAK} ${U} uninstall -y org.test.Hello >&2
ok "install extra data app with oci"
ok "install extra data app with oci"
build_extra_data_noruntime_app() {
local repo="$1"
local branch="$2"
DIR="$(mktemp -d)"
ARCH="$(flatpak --default-arch)"
mkdir -p "${DIR}/files/bin"
cp "${G_TEST_BUILDDIR}/apply-extra-static" "${DIR}/files/bin/apply_extra"
chmod +x "${DIR}/files/bin/apply_extra"
cat > "${DIR}/metadata" <<EOF
[Application]
name=org.test.ExtraDataNoRuntime
runtime=org.test.Platform/${ARCH}/${branch}
[Extra Data]
NoRuntime=true
uri=${EXTRA_DATA_URL}
size=${EXTRA_DATA_SIZE}
checksum=${EXTRA_DATA_SHA256}
EOF
flatpak build-finish "${DIR}" >&2
flatpak build-export ${FL_GPGARGS} "${repo}" "${DIR}" "${branch}" >&2
rm -rf "${DIR}"
}
if test -f "${G_TEST_BUILDDIR}/apply-extra-static"; then
build_extra_data_noruntime_app repos/test ${BRANCH}
update_repo ${REPONAME} ${COLLECTION_ID}
${FLATPAK} ${U} install --or-update -y ${REPONAME}-repo org.test.ExtraDataNoRuntime ${BRANCH} >&2
DEPLOY_DIR="$(${FLATPAK} ${U} info --show-location org.test.ExtraDataNoRuntime)"
assert_file_has_content "${DEPLOY_DIR}/files/extra/ran" "^noruntime-extra-data$"
${FLATPAK} ${U} uninstall -y org.test.ExtraDataNoRuntime >&2
ok "install+run extra data app with NoRuntime"
else
ok "# SKIP install+run extra data app with NoRuntime apply-extra-static not found"
fi