Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc635e4b

Browse files
committed
add tests for env param in hooks
Signed-off-by: lfbzhm <lifubang@acmcoder.com>
1 parent8fff44d commitc635e4b

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

‎tests/integration/hooks.bats‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,42 @@ function teardown() {
4242
[["$output"==*"error running$hook hook #1:"* ]]
4343
done
4444
}
45+
46+
@test"runc run [hook with env property]" {
47+
update_config'.process.args = ["/bin/true"]'
48+
update_config'.process.env = ["TEST_VAR=val"]'
49+
# All hooks except Poststop.
50+
forhookin prestart createRuntime createContainer startContainer poststart;do
51+
echo"testing hook$hook"
52+
# shellcheck disable=SC2016
53+
update_config'.hooks = {
54+
"'$hook'": [{
55+
"path": "/bin/sh",
56+
"args": ["/bin/sh", "-c", "[ \"$TEST_VAR\"==\"val\" ] && echo yes, we got val from the env TEST_VAR && exit 1 || exit 0"],
57+
"env": ["TEST_VAR=val"]
58+
}]
59+
}'
60+
TEST_VAR="val" runc run"test_hook-$hook"
61+
["$status"-ne 0 ]
62+
[["$output"==*"yes, we got val from the env TEST_VAR"* ]]
63+
done
64+
}
65+
66+
# https://github.com/opencontainers/runtime-spec/blob/v1.0.1/config.md#posix-platform-hooks
67+
@test"runc run [hook without env property should not inherit host env]" {
68+
update_config'.process.args = ["/bin/true"]'
69+
update_config'.process.env = ["TEST_VAR=val"]'
70+
# All hooks except Poststop.
71+
forhookin prestart createRuntime createContainer startContainer poststart;do
72+
echo"testing hook$hook"
73+
# shellcheck disable=SC2016
74+
update_config'.hooks = {
75+
"'$hook'": [{
76+
"path": "/bin/sh",
77+
"args": ["/bin/sh", "-c", "[[ \"$TEST_VAR\" == \"val\" ]] && echo \"$TEST_VAR\" && exit 1 || exit 0"]
78+
}]
79+
}'
80+
TEST_VAR="val" runc run"test_hook-$hook"
81+
["$status"-eq 0 ]
82+
done
83+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp