[RFC PATCH 0/9] [PIDNS] Tests

Ákos Uzonyi uzonyi.akos at gmail.com
Sat Jun 27 17:20:47 UTC 2020


From: Uzonyi Ákos <uzonyi.akos at gmail.com>

This week I was working on writing tests for the -Y flag. I'm sending this
series to show my current progress, and also to get some feedback whether this
approach to do tests looks OK.

tests/pidns.c is part of libtests.a. Each decoder test that prints PIDs calls
pidns_test_init_Y function at the beginning of main. This init function forks a
couple of times, and child processes execute the original test. First in the
original PID namespace, then multiple times in a new PID namespace with
various PID configurations (as a group leader, session leader, etc.). When
printing a PID in the tests the pidns_pid2str function is used to print the
translation comment.

The tests are executed by the test_pidns function in tests/init.sh. This passes
the necessary arguments to strace, and filters out the logs generated by the
parent process. This filtering is a bit hacky, so if you have better idea,
please tell me. Test_pidns runs strace twice, the second time in a new PID
namespace, to test PID translation when the /proc filesystem is from an
ancestor namespace.

Ákos Uzonyi (9):
  PID namespace translation support
  Use printpid in decoders
  Use printpid in print_sockaddr and printsiginfo
  Add SYS_FUNC(tkill)
  [squash] Fix pidns.c
  [squash] Use printargs_d for getpgrp decoding
  Implement testing framework for pidns
  [squash] Add copyright to new files
  Add pidns test for a couple of syscalls

 Makefile.am                   |   3 +
 affinity.c                    |   6 +-
 block.c                       |   2 +-
 bpf.c                         |   2 +-
 capability.c                  |   4 +-
 clone.c                       |  14 +-
 defs.h                        |  32 +-
 fcntl.c                       |  16 +-
 get_robust_list.c             |   3 +-
 getpid.c                      |  46 +++
 ioprio.c                      |  26 +-
 kcmp.c                        |   7 +-
 linux/32/syscallent.h         |   2 +-
 linux/64/syscallent.h         |   2 +-
 linux/alpha/syscallent.h      |   2 +-
 linux/arm/syscallent.h        |   2 +-
 linux/avr32/syscallent.h      |   2 +-
 linux/bfin/syscallent.h       |   2 +-
 linux/dummy.h                 |  10 +-
 linux/hppa/syscallent.h       |   2 +-
 linux/i386/syscallent.h       |   2 +-
 linux/ia64/syscallent.h       |   2 +-
 linux/m68k/syscallent.h       |   2 +-
 linux/microblaze/syscallent.h |   2 +-
 linux/mips/syscallent-n32.h   |   2 +-
 linux/mips/syscallent-n64.h   |   2 +-
 linux/mips/syscallent-o32.h   |   2 +-
 linux/powerpc/syscallent.h    |   2 +-
 linux/powerpc64/syscallent.h  |   2 +-
 linux/s390/syscallent.h       |   2 +-
 linux/s390x/syscallent.h      |   2 +-
 linux/sh/syscallent.h         |   2 +-
 linux/sh64/syscallent.h       |   2 +-
 linux/sparc/syscallent.h      |   2 +-
 linux/sparc64/syscallent.h    |   2 +-
 linux/x32/syscallent.h        |   2 +-
 linux/x86_64/syscallent.h     |   2 +-
 linux/xtensa/syscallent.h     |   2 +-
 msghdr.c                      |   6 +-
 net.c                         |   2 +-
 netlink.c                     |   5 +-
 numa.c                        |   6 +-
 pidfd_open.c                  |   2 +-
 pidns.c                       | 622 ++++++++++++++++++++++++++++++++++
 print_fields.h                |  28 +-
 print_group_req.c             |   2 +-
 printsiginfo.c                |  28 +-
 printsiginfo.h                |   2 +-
 process.c                     |   3 +-
 process_vm.c                  |   6 +-
 resource.c                    |  27 +-
 sched.c                       |  25 +-
 signal.c                      |  34 +-
 sock.c                        |  10 +-
 sockaddr.c                    |  35 +-
 strace.c                      |  10 +-
 syscall.c                     |  15 +
 tests/.gitignore              |   8 +
 tests/Makefile.am             |   8 +
 tests/bpf.c                   |   8 +-
 tests/gen_tests.in            |   9 +-
 tests/init.sh                 |  22 ++
 tests/ioctl_block.c           |   2 +-
 tests/kcmp.c                  |  25 +-
 tests/kill-Y.c                |   2 +
 tests/kill.c                  |  15 +-
 tests/pidfd_send_signal-Y.c   |   2 +
 tests/pidfd_send_signal.c     |  20 +-
 tests/pidns.c                 | 181 ++++++++++
 tests/pidns.h                 |  44 +++
 tests/rt_sigqueueinfo-Y.c     |   2 +
 tests/rt_sigqueueinfo.c       |  16 +-
 tests/rt_tgsigqueueinfo-Y.c   |   2 +
 tests/rt_tgsigqueueinfo.c     |  30 +-
 tests/sched_xetaffinity-Y.c   |   2 +
 tests/sched_xetaffinity.c     |  29 +-
 tests/xet_robust_list-Y.c     |   2 +
 tests/xet_robust_list.c       |  21 +-
 tests/xetpriority-Y.c         |   2 +
 tests/xetpriority.c           |  22 +-
 trie.c                        | 351 +++++++++++++++++++
 trie.h                        |  97 ++++++
 util.c                        |  20 +-
 wait.c                        |  35 +-
 84 files changed, 1873 insertions(+), 193 deletions(-)
 create mode 100644 getpid.c
 create mode 100644 pidns.c
 create mode 100644 tests/kill-Y.c
 create mode 100644 tests/pidfd_send_signal-Y.c
 create mode 100644 tests/pidns.c
 create mode 100644 tests/pidns.h
 create mode 100644 tests/rt_sigqueueinfo-Y.c
 create mode 100644 tests/rt_tgsigqueueinfo-Y.c
 create mode 100644 tests/sched_xetaffinity-Y.c
 create mode 100644 tests/xet_robust_list-Y.c
 create mode 100644 tests/xetpriority-Y.c
 create mode 100644 trie.c
 create mode 100644 trie.h

--
2.27.0



More information about the Strace-devel mailing list