2021-05-27 14:24:11 +02:00
#!/bin/bash -eu
2021-05-26 11:50:03 +02:00
2022-02-06 11:52:18 +01:00
ROOT = $( git rev-parse --show-toplevel)
2022-02-06 11:40:54 +01:00
2022-03-11 13:54:44 +01:00
RUNTIME = ${ 1 :- . } /youki
OCI_TEST_DIR = ${ ROOT } /tests/oci-runtime-tests/src/github.com/opencontainers/runtime-tools
PATTERN = ${ 2 :- . }
2022-02-06 11:40:54 +01:00
cd $OCI_TEST_DIR
2021-08-18 11:02:29 +02:00
2021-08-14 02:56:53 +02:00
test_cases = (
2021-08-18 11:02:29 +02:00
"create/create.t"
2021-08-14 02:56:53 +02:00
"default/default.t"
2021-08-18 11:02:29 +02:00
"delete/delete.t"
"delete_only_create_resources/delete_only_create_resources.t"
"delete_resources/delete_resources.t"
"hooks/hooks.t"
"hooks_stdin/hooks_stdin.t"
"hostname/hostname.t"
"kill/kill.t"
"kill_no_effect/kill_no_effect.t"
"killsig/killsig.t"
2021-08-21 08:54:09 +02:00
# This case includes checking for features that are excluded from linux kernel 5.0, so even runc doesn't pass it.
# ref. https://github.com/docker/cli/pull/2908
2021-08-18 11:02:29 +02:00
# "linux_cgroups_blkio/linux_cgroups_blkio.t"
"linux_cgroups_cpus/linux_cgroups_cpus.t"
2021-08-14 02:56:53 +02:00
"linux_cgroups_devices/linux_cgroups_devices.t"
2021-08-18 11:02:29 +02:00
"linux_cgroups_hugetlb/linux_cgroups_hugetlb.t"
2021-08-14 02:56:53 +02:00
"linux_cgroups_memory/linux_cgroups_memory.t"
"linux_cgroups_network/linux_cgroups_network.t"
2021-08-18 11:02:29 +02:00
"linux_cgroups_pids/linux_cgroups_pids.t"
2021-08-21 08:54:09 +02:00
# This case includes checking for features that are excluded from linux kernel 5.0, so even runc doesn't pass it.
# ref. https://github.com/docker/cli/pull/2908
2021-08-18 11:02:29 +02:00
# "linux_cgroups_relative_blkio/linux_cgroups_relative_blkio.t"
2021-09-05 04:15:01 +02:00
"linux_cgroups_relative_cpus/linux_cgroups_relative_cpus.t"
2021-08-14 02:56:53 +02:00
"linux_cgroups_relative_devices/linux_cgroups_relative_devices.t"
2021-08-18 11:02:29 +02:00
"linux_cgroups_relative_hugetlb/linux_cgroups_relative_hugetlb.t"
2021-08-14 02:56:53 +02:00
"linux_cgroups_relative_memory/linux_cgroups_relative_memory.t"
2021-08-18 11:02:29 +02:00
"linux_cgroups_relative_network/linux_cgroups_relative_network.t"
2021-08-14 02:56:53 +02:00
"linux_cgroups_relative_pids/linux_cgroups_relative_pids.t"
2021-08-18 11:02:29 +02:00
"linux_devices/linux_devices.t"
2021-09-06 17:50:07 +02:00
"linux_masked_paths/linux_masked_paths.t"
2021-08-18 11:02:29 +02:00
"linux_mount_label/linux_mount_label.t"
2021-08-30 05:54:33 +02:00
# This test case hangs on the Github Action. Runtime-tools has an issue filed from 2019 that the clean up step hangs. Otherwise, the test case passes.
# Ref: https://github.com/opencontainers/runtime-tools/issues/698
2021-08-18 11:02:29 +02:00
# "linux_ns_itype/linux_ns_itype.t"
2021-08-27 20:55:03 +02:00
"linux_ns_nopath/linux_ns_nopath.t"
"linux_ns_path/linux_ns_path.t"
2021-08-28 10:48:13 +02:00
"linux_ns_path_type/linux_ns_path_type.t"
2021-12-30 23:44:13 +01:00
# This test case requires that an apparmor profile named 'acme_secure_profile' has been installed on the system. It needs to allow the capabilities
2021-09-21 01:13:13 +02:00
# validated by runtime-tools otherwise the test case will fail despite the profile being available.
2021-08-18 11:02:29 +02:00
# "linux_process_apparmor_profile/linux_process_apparmor_profile.t"
2021-08-21 11:39:18 +02:00
"linux_readonly_paths/linux_readonly_paths.t"
2021-09-19 06:36:10 +02:00
"linux_rootfs_propagation/linux_rootfs_propagation.t"
2021-09-14 08:55:01 +02:00
"linux_seccomp/linux_seccomp.t"
2021-08-14 02:56:53 +02:00
"linux_sysctl/linux_sysctl.t"
2021-09-10 07:22:19 +02:00
"linux_uid_mappings/linux_uid_mappings.t"
2022-11-28 06:28:32 +01:00
# "misc_props/misc_props.t" runc also fails this, check out https://github.com/containers/youki/pull/1347#issuecomment-1315332775
2021-09-05 15:26:28 +02:00
"mounts/mounts.t"
2021-09-25 04:58:23 +02:00
# This test case passed on local box, but not on Github Action. `runc` also fails on Github Action, so likely it is an issue with the test.
# "pidfile/pidfile.t"
2021-08-14 02:56:53 +02:00
"poststart/poststart.t"
"poststart_fail/poststart_fail.t"
"poststop/poststop.t"
2021-08-18 11:02:29 +02:00
"poststop_fail/poststop_fail.t"
"prestart/prestart.t"
"prestart_fail/prestart_fail.t"
2021-08-22 09:51:30 +02:00
"process/process.t"
2021-08-18 11:02:29 +02:00
"process_capabilities/process_capabilities.t"
"process_capabilities_fail/process_capabilities_fail.t"
2021-08-31 07:45:45 +02:00
"process_oom_score_adj/process_oom_score_adj.t"
2021-08-18 11:02:29 +02:00
"process_rlimits/process_rlimits.t"
"process_rlimits_fail/process_rlimits_fail.t"
2021-08-28 20:22:43 +02:00
"process_user/process_user.t"
2021-08-24 16:43:00 +02:00
"root_readonly_true/root_readonly_true.t"
2021-08-18 11:02:29 +02:00
# Record the tests that runc also fails to pass below, maybe we will fix this by origin integration test, issue: https://github.com/containers/youki/issues/56
# "start/start.t"
"state/state.t"
2021-08-14 02:56:53 +02:00
)
2021-08-19 14:28:46 +02:00
2021-12-30 22:44:36 +01:00
check_environment( ) {
2021-08-19 14:28:46 +02:00
test_case = $1
2021-08-20 14:27:08 +02:00
if [ [ $test_case = ~ .*( memory| hugetlb) .t ] ] ; then
2021-08-19 14:28:46 +02:00
if [ [ ! -e "/sys/fs/cgroup/memory/memory.memsw.limit_in_bytes" ] ] ; then
return 1
2021-09-05 04:15:01 +02:00
fi
2021-08-19 14:28:46 +02:00
fi
2022-12-12 13:57:25 +01:00
if [ [ $test_case = = "delete_only_create_resources/delete_only_create_resources.t" ] ] ; then
if [ [ ! -e "/sys/fs/cgroup/pids/cgrouptest/tasks" ] ] ; then
return 1
fi
fi
2021-08-19 14:28:46 +02:00
}
2022-05-09 14:10:04 +02:00
if [ [ ! -e $RUNTIME ] ] ; then
if ! which $RUNTIME ; then
echo " $RUNTIME not found "
exit 1
fi
fi
2021-08-18 11:02:29 +02:00
for case in " ${ test_cases [@] } " ; do
2022-02-06 11:52:18 +01:00
if [ [ ! -e " ${ OCI_TEST_DIR } /validation/ $case " ] ] ; then
2022-03-11 13:54:44 +01:00
GO111MODULE = auto GOPATH = ${ ROOT } /tests/oci-runtime-tests make runtimetest validation-executables
2021-08-18 11:02:29 +02:00
break
fi
done
2021-08-14 02:58:52 +02:00
2021-05-26 11:50:03 +02:00
for case in " ${ test_cases [@] } " ; do
2021-12-30 22:44:36 +01:00
if ! check_environment $case ; then
2023-06-08 06:49:17 +02:00
echo " Skip $case because your environment doesn't support this test case "
2021-08-19 14:28:46 +02:00
continue
fi
2021-08-24 16:59:54 +02:00
if [ $PATTERN != "." ] && [ [ ! $case = ~ $PATTERN ] ] ; then
2021-09-05 04:15:01 +02:00
continue
fi
2021-08-24 16:56:07 +02:00
2021-05-26 11:50:03 +02:00
echo " Running $case "
2021-08-24 11:49:54 +02:00
logfile = " ./log/ $case .log "
mkdir -p " $( dirname $logfile ) "
2022-02-06 11:52:18 +01:00
sudo RUST_BACKTRACE = 1 RUNTIME = ${ RUNTIME } ${ OCI_TEST_DIR } /validation/$case >$logfile 2>& 1 || ( cat $logfile && exit 1)
2021-08-24 14:07:41 +02:00
if [ 0 -ne $( grep "not ok" $logfile | wc -l ) ] ; then
2022-12-12 13:57:25 +01:00
if [ 0 -eq $( grep "# cgroupv2 is not supported yet " $logfile | wc -l ) ] ; then
2023-06-08 06:49:17 +02:00
echo " Skip $case because oci-runtime-tools doesn't support cgroup v2 "
2022-12-12 13:57:25 +01:00
continue ;
fi
cat $logfile
exit 1
2021-05-26 11:50:03 +02:00
fi
2021-05-30 11:30:40 +02:00
sleep 1
2021-05-26 11:50:03 +02:00
done