History

Merge tag 'linux-kselftest-5.5-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest

Pull kselftest fixes from Shuah Khan: - ftrace and safesetid test fixes from Masami Hiramatsu - Kunit fixes from Brendan Higgins, Iurii Zaikin, and Heidi Fahim - Kselftest framework fixes from SeongJae Park and Michael Ellerman * tag 'linux-kselftest-5.5-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: kselftest: Support old perl versions kselftest/runner: Print new line in print of timeout log selftests: Fix dangling documentation references to kselftest_module.sh Documentation: kunit: add documentation for kunit_tool Documentation: kunit: fix typos and gramatical errors kunit: testing kunit: Bug fix in test_run_timeout function fs/ext4/inode-test: Fix inode test on 32 bit platforms. selftests: safesetid: Fix Makefile to set correct test program selftests: safesetid: Check the return value of setuid/setgid selftests: safesetid: Move link library to LDLIBS selftests/ftrace: Fix multiple kprobe testcase selftests/ftrace: Do not to use absolute debugfs path selftests/ftrace: Fix ftrace test cases to check unsupported selftests/ftrace: Fix to check the existence of set_ftrace_filter

Linus Torvalds committed 6 years ago

Commit 6afa8732 parents 4c80ba3 4eac73419 files · +119 −40Browse files

Unified · Split

19 files
  1. Documentation/dev-tools/kselftest.rst +4 −4
  2. Documentation/dev-tools/kunit/index.rst +1 −0
  3. Documentation/dev-tools/kunit/kunit-tool.rst +57 −0
  4. Documentation/dev-tools/kunit/start.rst +8 −5
  5. Documentation/dev-tools/kunit/usage.rst +12 −12
  6. fs/ext4/inode-test.c +1 −1
  7. tools/testing/kunit/kunit_tool_test.py +1 −1
  8. tools/testing/selftests/ftrace/test.d/ftrace/func-filter-stacktrace.tc +2 −0
  9. tools/testing/selftests/ftrace/test.d/ftrace/func_cpumask.tc +5 −0
  10. tools/testing/selftests/ftrace/test.d/functions +4 −1
  11. tools/testing/selftests/ftrace/test.d/kprobe/multiple_kprobes.tc +3 −3
  12. tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-action-hist-xfail.tc +2 −2
  13. tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onchange-action-hist.tc +1 −1
  14. tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-snapshot-action-hist.tc +2 −2
  15. tools/testing/selftests/kselftest/module.sh +1 −1
  16. tools/testing/selftests/kselftest/prefix.pl +1 −0
  17. tools/testing/selftests/kselftest/runner.sh +1 −0
  18. tools/testing/selftests/safesetid/Makefile +3 −2
  19. tools/testing/selftests/safesetid/safesetid-test.c +10 −5
Documentation/dev-tools/kselftest.rst+4−4
@@ -203,12 +203,12 @@ Test Module · 202 unmodified lines
203Kselftest tests the kernel from userspace. Sometimes things need203Kselftest tests the kernel from userspace. Sometimes things need
204testing from within the kernel, one method of doing this is to create a204testing from within the kernel, one method of doing this is to create a
205test module. We can tie the module into the kselftest framework by205test module. We can tie the module into the kselftest framework by
206using a shell script test runner. ``kselftest_module.sh`` is designed206using a shell script test runner. ``kselftest/module.sh`` is designed
207to facilitate this process. There is also a header file provided to207to facilitate this process. There is also a header file provided to
208assist writing kernel modules that are for use with kselftest:208assist writing kernel modules that are for use with kselftest:
209 209
210- ``tools/testing/kselftest/kselftest_module.h``210- ``tools/testing/kselftest/kselftest_module.h``
211- ``tools/testing/kselftest/kselftest_module.sh``211- ``tools/testing/kselftest/kselftest/module.sh``
212 212
213How to use213How to use
214----------214----------
@@ -247,7 +247,7 @@ A bare bones test module might look like this: · 32 unmodified lines
247 247
248 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt248 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
249 249
250 #include "../tools/testing/selftests/kselftest_module.h"250 #include "../tools/testing/selftests/kselftest/module.h"
251 251
252 KSTM_MODULE_GLOBALS();252 KSTM_MODULE_GLOBALS();
253 253
@@ -276,7 +276,7 @@ Example test script · 22 unmodified lines
276 276
277 #!/bin/bash277 #!/bin/bash
278 # SPDX-License-Identifier: GPL-2.0+278 # SPDX-License-Identifier: GPL-2.0+
279 $(dirname $0)/../kselftest_module.sh "foo" test_foo279 $(dirname $0)/../kselftest/module.sh "foo" test_foo
280 280
281 281
282Test Harness282Test Harness
Documentation/dev-tools/kunit/index.rst+1−0
@@ -9,6 +9,7 @@ KUnit - Unit Testing for the Linux Kernel · 8 unmodified lines
9 9
10 start10 start
11 usage11 usage
12 kunit-tool
12 api/index13 api/index
13 faq14 faq
14 15
Documentation/dev-tools/kunit/kunit-tool.rst+57−0
@@ -0,0 +1,57 @@
1.. SPDX-License-Identifier: GPL-2.0
2
3=================
4kunit_tool How-To
5=================
6
7What is kunit_tool?
8===================
9
10kunit_tool is a script (``tools/testing/kunit/kunit.py``) that aids in building
11the Linux kernel as UML (`User Mode Linux
12<http://user-mode-linux.sourceforge.net/>`_), running KUnit tests, parsing
13the test results and displaying them in a user friendly manner.
14
15What is a kunitconfig?
16======================
17
18It's just a defconfig that kunit_tool looks for in the base directory.
19kunit_tool uses it to generate a .config as you might expect. In addition, it
20verifies that the generated .config contains the CONFIG options in the
21kunitconfig; the reason it does this is so that it is easy to be sure that a
22CONFIG that enables a test actually ends up in the .config.
23
24How do I use kunit_tool?
25========================
26
27If a kunitconfig is present at the root directory, all you have to do is:
28
29.. code-block:: bash
30
31 ./tools/testing/kunit/kunit.py run
32
33However, you most likely want to use it with the following options:
34
35.. code-block:: bash
36
37 ./tools/testing/kunit/kunit.py run --timeout=30 --jobs=`nproc --all`
38
39- ``--timeout`` sets a maximum amount of time to allow tests to run.
40- ``--jobs`` sets the number of threads to use to build the kernel.
41
42If you just want to use the defconfig that ships with the kernel, you can
43append the ``--defconfig`` flag as well:
44
45.. code-block:: bash
46
47 ./tools/testing/kunit/kunit.py run --timeout=30 --jobs=`nproc --all` --defconfig
48
49.. note::
50 This command is particularly helpful for getting started because it
51 just works. No kunitconfig needs to be present.
52
53For a list of all the flags supported by kunit_tool, you can run:
54
55.. code-block:: bash
56
57 ./tools/testing/kunit/kunit.py run --help
Documentation/dev-tools/kunit/start.rst+8−5
@@ -19,11 +19,14 @@ The wrapper can be run with: · 18 unmodified lines
19 19
20.. code-block:: bash20.. code-block:: bash
21 21
22 ./tools/testing/kunit/kunit.py run22 ./tools/testing/kunit/kunit.py run --defconfig
23
24For more information on this wrapper (also called kunit_tool) checkout the
25:doc:`kunit-tool` page.
23 26
24Creating a kunitconfig27Creating a kunitconfig
25======================28======================
26The Python script is a thin wrapper around Kbuild as such, it needs to be29The Python script is a thin wrapper around Kbuild. As such, it needs to be
27configured with a ``kunitconfig`` file. This file essentially contains the30configured with a ``kunitconfig`` file. This file essentially contains the
28regular Kernel config, with the specific test targets as well.31regular Kernel config, with the specific test targets as well.
29 32
@@ -59,8 +62,8 @@ If everything worked correctly, you should see the following: · 29 unmodified lines
59followed by a list of tests that are run. All of them should be passing.62followed by a list of tests that are run. All of them should be passing.
60 63
61.. note::64.. note::
62 Because it is building a lot of sources for the first time, the ``Building65 Because it is building a lot of sources for the first time, the
63 kunit kernel`` step may take a while.66 ``Building KUnit kernel`` step may take a while.
64 67
65Writing your first test68Writing your first test
66=======================69=======================
@@ -159,7 +162,7 @@ Now you can run the test: · 92 unmodified lines
159 162
160.. code-block:: bash163.. code-block:: bash
161 164
162 ./tools/testing/kunit/kunit.py165 ./tools/testing/kunit/kunit.py run
163 166
164You should see the following failure:167You should see the following failure:
165 168
Documentation/dev-tools/kunit/usage.rst+12−12
@@ -16,7 +16,7 @@ Organization of this document · 15 unmodified lines
16=============================16=============================
17 17
18This document is organized into two main sections: Testing and Isolating18This document is organized into two main sections: Testing and Isolating
19Behavior. The first covers what a unit test is and how to use KUnit to write19Behavior. The first covers what unit tests are and how to use KUnit to write
20them. The second covers how to use KUnit to isolate code and make it possible20them. The second covers how to use KUnit to isolate code and make it possible
21to unit test code that was otherwise un-unit-testable.21to unit test code that was otherwise un-unit-testable.
22 22
@@ -174,13 +174,13 @@ Test Suites · 151 unmodified lines
174~~~~~~~~~~~174~~~~~~~~~~~
175 175
176Now obviously one unit test isn't very helpful; the power comes from having176Now obviously one unit test isn't very helpful; the power comes from having
177many test cases covering all of your behaviors. Consequently it is common to177many test cases covering all of a unit's behaviors. Consequently it is common
178have many *similar* tests; in order to reduce duplication in these closely178to have many *similar* tests; in order to reduce duplication in these closely
179related tests most unit testing frameworks provide the concept of a *test179related tests most unit testing frameworks - including KUnit - provide the
180suite*, in KUnit we call it a *test suite*; all it is is just a collection of180concept of a *test suite*. A *test suite* is just a collection of test cases
181test cases for a unit of code with a set up function that gets invoked before181for a unit of code with a set up function that gets invoked before every test
182every test cases and then a tear down function that gets invoked after every182case and then a tear down function that gets invoked after every test case
183test case completes.183completes.
184 184
185Example:185Example:
186 186
@@ -211,7 +211,7 @@ KUnit test framework. · 24 unmodified lines
211.. note::211.. note::
212 A test case will only be run if it is associated with a test suite.212 A test case will only be run if it is associated with a test suite.
213 213
214For a more information on these types of things see the :doc:`api/test`.214For more information on these types of things see the :doc:`api/test`.
215 215
216Isolating Behavior216Isolating Behavior
217==================217==================
@@ -338,7 +338,7 @@ We can easily test this code by *faking out* the underlying EEPROM: · 120 unmodified lines
338 return count;338 return count;
339 }339 }
340 340
341 ssize_t fake_eeprom_write(struct eeprom *this, size_t offset, const char *buffer, size_t count)341 ssize_t fake_eeprom_write(struct eeprom *parent, size_t offset, const char *buffer, size_t count)
342 {342 {
343 struct fake_eeprom *this = container_of(parent, struct fake_eeprom, parent);343 struct fake_eeprom *this = container_of(parent, struct fake_eeprom, parent);
344 344
@@ -454,7 +454,7 @@ KUnit on non-UML architectures · 109 unmodified lines
454By default KUnit uses UML as a way to provide dependencies for code under test.454By default KUnit uses UML as a way to provide dependencies for code under test.
455Under most circumstances KUnit's usage of UML should be treated as an455Under most circumstances KUnit's usage of UML should be treated as an
456implementation detail of how KUnit works under the hood. Nevertheless, there456implementation detail of how KUnit works under the hood. Nevertheless, there
457are instances where being able to run architecture specific code, or test457are instances where being able to run architecture specific code or test
458against real hardware is desirable. For these reasons KUnit supports running on458against real hardware is desirable. For these reasons KUnit supports running on
459other architectures.459other architectures.
460 460
@@ -557,7 +557,7 @@ run your tests on your hardware setup just by compiling for your architecture. · 96 unmodified lines
557.. important::557.. important::
558 Always prefer tests that run on UML to tests that only run under a particular558 Always prefer tests that run on UML to tests that only run under a particular
559 architecture, and always prefer tests that run under QEMU or another easy559 architecture, and always prefer tests that run under QEMU or another easy
560 (and monitarily free) to obtain software environment to a specific piece of560 (and monetarily free) to obtain software environment to a specific piece of
561 hardware.561 hardware.
562 562
563Nevertheless, there are still valid reasons to write an architecture or hardware563Nevertheless, there are still valid reasons to write an architecture or hardware
fs/ext4/inode-test.c+1−1
@@ -25,7 +25,7 @@ · 24 unmodified lines
25 * For constructing the negative timestamp lower bound value.25 * For constructing the negative timestamp lower bound value.
26 * binary: 10000000 00000000 00000000 0000000026 * binary: 10000000 00000000 00000000 00000000
27 */27 */
28#define LOWER_MSB_1 (-0x80000000L)28#define LOWER_MSB_1 (-(UPPER_MSB_0) - 1L) /* avoid overflow */
29/*29/*
30 * For constructing the negative timestamp upper bound value.30 * For constructing the negative timestamp upper bound value.
31 * binary: 11111111 11111111 11111111 1111111131 * binary: 11111111 11111111 11111111 11111111
tools/testing/kunit/kunit_tool_test.py+1−1
@@ -199,7 +199,7 @@ class KUnitMainTest(unittest.TestCase): · 198 unmodified lines
199 timeout = 3453199 timeout = 3453
200 kunit.main(['run', '--timeout', str(timeout)], self.linux_source_mock)200 kunit.main(['run', '--timeout', str(timeout)], self.linux_source_mock)
201 assert self.linux_source_mock.build_reconfig.call_count == 1201 assert self.linux_source_mock.build_reconfig.call_count == 1
202 self.linux_source_mock.run_kernel.assert_called_once_with(timeout=timeout)202 self.linux_source_mock.run_kernel.assert_called_once_with(build_dir=None, timeout=timeout)
203 self.print_mock.assert_any_call(StrContains('Testing complete.'))203 self.print_mock.assert_any_call(StrContains('Testing complete.'))
204 204
205if __name__ == '__main__':205if __name__ == '__main__':
tools/testing/selftests/ftrace/test.d/ftrace/func-filter-stacktrace.tc+2−0
@@ -3,6 +3,8 @@ · 2 unmodified lines
3# description: ftrace - stacktrace filter command3# description: ftrace - stacktrace filter command
4# flags: instance4# flags: instance
5 5
6[ ! -f set_ftrace_filter ] && exit_unsupported
7
6echo _do_fork:stacktrace >> set_ftrace_filter8echo _do_fork:stacktrace >> set_ftrace_filter
7 9
8grep -q "_do_fork:stacktrace:unlimited" set_ftrace_filter10grep -q "_do_fork:stacktrace:unlimited" set_ftrace_filter
tools/testing/selftests/ftrace/test.d/ftrace/func_cpumask.tc+5−0
@@ -15,6 +15,11 @@ if [ $NP -eq 1 ] ;then · 14 unmodified lines
15 exit_unresolved15 exit_unresolved
16fi16fi
17 17
18if ! grep -q "function" available_tracers ; then
19 echo "Function trace is not enabled"
20 exit_unsupported
21fi
22
18ORIG_CPUMASK=`cat tracing_cpumask`23ORIG_CPUMASK=`cat tracing_cpumask`
19 24
20do_reset() {25do_reset() {
tools/testing/selftests/ftrace/test.d/functions+4−1
@@ -46,6 +46,9 @@ reset_events_filter() { # reset all current setting filters · 45 unmodified lines
46}46}
47 47
48reset_ftrace_filter() { # reset all triggers in set_ftrace_filter48reset_ftrace_filter() { # reset all triggers in set_ftrace_filter
49 if [ ! -f set_ftrace_filter ]; then
50 return 0
51 fi
49 echo > set_ftrace_filter52 echo > set_ftrace_filter
50 grep -v '^#' set_ftrace_filter | while read t; do53 grep -v '^#' set_ftrace_filter | while read t; do
51 tr=`echo $t | cut -d: -f2`54 tr=`echo $t | cut -d: -f2`
@@ -93,7 +96,7 @@ initialize_ftrace() { # Reset ftrace to initial-state · 41 unmodified lines
93 disable_events96 disable_events
94 [ -f set_event_pid ] && echo > set_event_pid97 [ -f set_event_pid ] && echo > set_event_pid
95 [ -f set_ftrace_pid ] && echo > set_ftrace_pid98 [ -f set_ftrace_pid ] && echo > set_ftrace_pid
96 [ -f set_ftrace_filter ] && echo | tee set_ftrace_*99 [ -f set_ftrace_notrace ] && echo > set_ftrace_notrace
97 [ -f set_graph_function ] && echo | tee set_graph_*100 [ -f set_graph_function ] && echo | tee set_graph_*
98 [ -f stack_trace_filter ] && echo > stack_trace_filter101 [ -f stack_trace_filter ] && echo > stack_trace_filter
99 [ -f kprobe_events ] && echo > kprobe_events102 [ -f kprobe_events ] && echo > kprobe_events
tools/testing/selftests/ftrace/test.d/kprobe/multiple_kprobes.tc+3−3
@@ -20,9 +20,9 @@ while read i; do · 19 unmodified lines
20 test $N -eq 256 && break20 test $N -eq 256 && break
21done21done
22 22
23L=`wc -l kprobe_events`23L=`cat kprobe_events | wc -l`
24if [ $L -ne $N ]; then24if [ $L -ne 256 ]; then
25 echo "The number of kprobes events ($L) is not $N"25 echo "The number of kprobes events ($L) is not 256"
26 exit_fail26 exit_fail
27fi27fi
28 28
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-action-hist-xfail.tc+2−2
@@ -21,10 +21,10 @@ grep -q "snapshot()" README || exit_unsupported # version issue · 20 unmodified lines
21 21
22echo "Test expected snapshot action failure"22echo "Test expected snapshot action failure"
23 23
24echo 'hist:keys=comm:onmatch(sched.sched_wakeup).snapshot()' >> /sys/kernel/debug/tracing/events/sched/sched_waking/trigger && exit_fail24echo 'hist:keys=comm:onmatch(sched.sched_wakeup).snapshot()' >> events/sched/sched_waking/trigger && exit_fail
25 25
26echo "Test expected save action failure"26echo "Test expected save action failure"
27 27
28echo 'hist:keys=comm:onmatch(sched.sched_wakeup).save(comm,prio)' >> /sys/kernel/debug/tracing/events/sched/sched_waking/trigger && exit_fail28echo 'hist:keys=comm:onmatch(sched.sched_wakeup).save(comm,prio)' >> events/sched/sched_waking/trigger && exit_fail
29 29
30exit_xfail30exit_xfail
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onchange-action-hist.tc+1−1
@@ -16,7 +16,7 @@ grep -q "onchange(var)" README || exit_unsupported # version issue · 15 unmodified lines
16 16
17echo "Test onchange action"17echo "Test onchange action"
18 18
19echo 'hist:keys=comm:newprio=prio:onchange($newprio).save(comm,prio) if comm=="ping"' >> /sys/kernel/debug/tracing/events/sched/sched_waking/trigger19echo 'hist:keys=comm:newprio=prio:onchange($newprio).save(comm,prio) if comm=="ping"' >> events/sched/sched_waking/trigger
20 20
21ping $LOCALHOST -c 321ping $LOCALHOST -c 3
22nice -n 1 ping $LOCALHOST -c 322nice -n 1 ping $LOCALHOST -c 3
tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-snapshot-action-hist.tc+2−2
@@ -23,9 +23,9 @@ grep -q "snapshot()" README || exit_unsupported # version issue · 22 unmodified lines
23 23
24echo "Test snapshot action"24echo "Test snapshot action"
25 25
26echo 1 > /sys/kernel/debug/tracing/events/sched/enable26echo 1 > events/sched/enable
27 27
28echo 'hist:keys=comm:newprio=prio:onchange($newprio).save(comm,prio):onchange($newprio).snapshot() if comm=="ping"' >> /sys/kernel/debug/tracing/events/sched/sched_waking/trigger28echo 'hist:keys=comm:newprio=prio:onchange($newprio).save(comm,prio):onchange($newprio).snapshot() if comm=="ping"' >> events/sched/sched_waking/trigger
29 29
30ping $LOCALHOST -c 330ping $LOCALHOST -c 3
31nice -n 1 ping $LOCALHOST -c 331nice -n 1 ping $LOCALHOST -c 3
tools/testing/selftests/kselftest/module.sh+1−1
@@ -9,7 +9,7 @@ · 8 unmodified lines
9#9#
10# #!/bin/sh10# #!/bin/sh
11# SPDX-License-Identifier: GPL-2.0+11# SPDX-License-Identifier: GPL-2.0+
12# $(dirname $0)/../kselftest_module.sh "description" module_name12# $(dirname $0)/../kselftest/module.sh "description" module_name
13#13#
14# Example: tools/testing/selftests/lib/printf.sh14# Example: tools/testing/selftests/lib/printf.sh
15 15
tools/testing/selftests/kselftest/prefix.pl+1−0
@@ -3,6 +3,7 @@ · 2 unmodified lines
3# Prefix all lines with "# ", unbuffered. Command being piped in may need3# Prefix all lines with "# ", unbuffered. Command being piped in may need
4# to have unbuffering forced with "stdbuf -i0 -o0 -e0 $cmd".4# to have unbuffering forced with "stdbuf -i0 -o0 -e0 $cmd".
5use strict;5use strict;
6use IO::Handle;
6 7
7binmode STDIN;8binmode STDIN;
8binmode STDOUT;9binmode STDOUT;
tools/testing/selftests/kselftest/runner.sh+1−0
@@ -79,6 +79,7 @@ run_one() · 78 unmodified lines
79 if [ $rc -eq $skip_rc ]; then \79 if [ $rc -eq $skip_rc ]; then \
80 echo "not ok $test_num $TEST_HDR_MSG # SKIP"80 echo "not ok $test_num $TEST_HDR_MSG # SKIP"
81 elif [ $rc -eq $timeout_rc ]; then \81 elif [ $rc -eq $timeout_rc ]; then \
82 echo "#"
82 echo "not ok $test_num $TEST_HDR_MSG # TIMEOUT"83 echo "not ok $test_num $TEST_HDR_MSG # TIMEOUT"
83 else84 else
84 echo "not ok $test_num $TEST_HDR_MSG # exit=$rc"85 echo "not ok $test_num $TEST_HDR_MSG # exit=$rc"
tools/testing/selftests/safesetid/Makefile+3−2
@@ -1,8 +1,9 @@
1# SPDX-License-Identifier: GPL-2.01# SPDX-License-Identifier: GPL-2.0
2# Makefile for mount selftests.2# Makefile for mount selftests.
3CFLAGS = -Wall -lcap -O23CFLAGS = -Wall -O2
4LDLIBS = -lcap
4 5
5TEST_PROGS := run_tests.sh6TEST_PROGS := safesetid-test.sh
6TEST_GEN_FILES := safesetid-test7TEST_GEN_FILES := safesetid-test
7 8
8include ../lib.mk9include ../lib.mk
tools/testing/selftests/safesetid/safesetid-test.c+10−5
@@ -213,7 +213,8 @@ static void test_setuid(uid_t child_uid, bool expect_success) · 212 unmodified lines
213 }213 }
214 214
215 if (cpid == 0) { /* Code executed by child */215 if (cpid == 0) { /* Code executed by child */
216 setuid(child_uid);216 if (setuid(child_uid) < 0)
217 exit(EXIT_FAILURE);
217 if (getuid() == child_uid)218 if (getuid() == child_uid)
218 exit(EXIT_SUCCESS);219 exit(EXIT_SUCCESS);
219 else220 else
@@ -291,8 +292,10 @@ int main(int argc, char **argv) · 71 unmodified lines
291 292
292 // First test to make sure we can write userns mappings from a user293 // First test to make sure we can write userns mappings from a user
293 // that doesn't have any restrictions (as long as it has CAP_SETUID);294 // that doesn't have any restrictions (as long as it has CAP_SETUID);
294 setuid(NO_POLICY_USER);295 if (setuid(NO_POLICY_USER) < 0)
295 setgid(NO_POLICY_USER);296 die("Error with set uid(%d)\n", NO_POLICY_USER);
297 if (setgid(NO_POLICY_USER) < 0)
298 die("Error with set gid(%d)\n", NO_POLICY_USER);
296 299
297 // Take away all but setid caps300 // Take away all but setid caps
298 drop_caps(true);301 drop_caps(true);
@@ -306,8 +309,10 @@ int main(int argc, char **argv) · 7 unmodified lines
306 die("test_userns failed when it should work\n");309 die("test_userns failed when it should work\n");
307 }310 }
308 311
309 setuid(RESTRICTED_PARENT);312 if (setuid(RESTRICTED_PARENT) < 0)
310 setgid(RESTRICTED_PARENT);313 die("Error with set uid(%d)\n", RESTRICTED_PARENT);
314 if (setgid(RESTRICTED_PARENT) < 0)
315 die("Error with set gid(%d)\n", RESTRICTED_PARENT);
311 316
312 test_setuid(ROOT_USER, false);317 test_setuid(ROOT_USER, false);
313 test_setuid(ALLOWED_CHILD1, true);318 test_setuid(ALLOWED_CHILD1, true);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t