Enhance related regression tests
This commit is contained in:
parent
0bff86582a
commit
0fb306e0af
|
|
@ -0,0 +1,51 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <syscall.h>
|
||||
#include "../test.h"
|
||||
|
||||
#define FILENAME "/tmp/exec_test.stat"
|
||||
|
||||
FN_SETUP(check_child_stat)
|
||||
{
|
||||
int pid = -1;
|
||||
int exit_code = -1;
|
||||
int pipefd = -1;
|
||||
|
||||
FILE *file = CHECK_WITH(fopen(FILENAME, "r"), _ret != NULL);
|
||||
fscanf(file, "%d %d %d", &pid, &exit_code, &pipefd);
|
||||
CHECK(fclose(file));
|
||||
CHECK(unlink(FILENAME));
|
||||
|
||||
CHECK_WITH(getpid(), _ret == pid);
|
||||
CHECK_WITH(syscall(SYS_gettid), _ret == pid);
|
||||
|
||||
if (pipefd != 0) {
|
||||
CHECK_WITH(access("/proc/self/fd/100", F_OK),
|
||||
_ret == -1 && errno == ENOENT);
|
||||
CHECK_WITH(access("/proc/thread-self/fd/100", F_OK),
|
||||
_ret == -1 && errno == ENOENT);
|
||||
CHECK_WITH(close(pipefd), _ret == -1 && errno == EBADF);
|
||||
}
|
||||
|
||||
FILE *stat;
|
||||
int id, flag;
|
||||
|
||||
id = flag = -1;
|
||||
CHECK_WITH(stat = fopen("/proc/self/stat", "r"), stat != NULL);
|
||||
fscanf(stat, "%d (execve_mt_child) %n", &id, &flag);
|
||||
CHECK(fclose(stat));
|
||||
CHECK_WITH(getpid(), _ret == id && flag != -1);
|
||||
|
||||
id = flag = -1;
|
||||
CHECK_WITH(stat = fopen("/proc/thread-self/stat", "r"), stat != NULL);
|
||||
fscanf(stat, "%d (execve_mt_child) %n", &id, &flag);
|
||||
CHECK(fclose(stat));
|
||||
CHECK_WITH(syscall(SYS_gettid), _ret == id && flag != -1);
|
||||
|
||||
exit(exit_code);
|
||||
}
|
||||
END_SETUP()
|
||||
|
|
@ -39,9 +39,24 @@ int exec_child()
|
|||
}
|
||||
|
||||
char exec_path[PATH_MAX];
|
||||
char *child_name = "execve_multithread_child";
|
||||
char *child_name = "execve_mt_child";
|
||||
sprintf(exec_path, "%s/%s", dir_name, child_name);
|
||||
|
||||
FILE *stat;
|
||||
int id, flag;
|
||||
|
||||
id = flag = -1;
|
||||
CHECK_WITH(stat = fopen("/proc/self/stat", "r"), stat != NULL);
|
||||
fscanf(stat, "%d (execve_mt_paren) %n", &id, &flag);
|
||||
CHECK(fclose(stat));
|
||||
CHECK_WITH(getpid(), _ret == id && flag != -1);
|
||||
|
||||
id = flag = -1;
|
||||
CHECK_WITH(stat = fopen("/proc/thread-self/stat", "r"), stat != NULL);
|
||||
fscanf(stat, "%d (execve_mt_paren) %n", &id, &flag);
|
||||
CHECK(fclose(stat));
|
||||
CHECK_WITH(syscall(SYS_gettid), _ret == id && flag != -1);
|
||||
|
||||
CHECK(execl(exec_path, child_name, NULL));
|
||||
|
||||
exit(EXIT_FAILURE);
|
||||
|
|
@ -157,6 +172,8 @@ FN_TEST(clone_files)
|
|||
pid = TEST_SUCC(sys_clone3(&args));
|
||||
|
||||
if (pid == 0) {
|
||||
CHECK(access("/proc/self/fd/100", F_OK));
|
||||
CHECK(access("/proc/thread-self/fd/100", F_OK));
|
||||
CHECK(write_stat(102, dupped_pipe_fd));
|
||||
|
||||
struct info info = { .should_sleep = false };
|
||||
|
|
@ -176,4 +193,4 @@ FN_TEST(clone_files)
|
|||
TEST_SUCC(close(dupped_pipe_fd));
|
||||
TEST_ERRNO(close(pipefds[1]), EBADF);
|
||||
}
|
||||
END_TEST()
|
||||
END_TEST()
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <syscall.h>
|
||||
#include <signal.h>
|
||||
#include "../test.h"
|
||||
|
||||
#define FILENAME "/tmp/exec_test.stat"
|
||||
|
||||
FN_SETUP(check_child_stat)
|
||||
{
|
||||
FILE *file = CHECK(fopen(FILENAME, "r"));
|
||||
|
||||
int pid;
|
||||
int exit_code;
|
||||
int pipefd;
|
||||
|
||||
fscanf(file, "%d %d %d", &pid, &exit_code, &pipefd);
|
||||
CHECK_WITH(getpid(), _ret == pid);
|
||||
CHECK_WITH(syscall(SYS_gettid), _ret == pid);
|
||||
|
||||
if (pipefd != 0) {
|
||||
CHECK_WITH(close(pipefd), errno == EBADF);
|
||||
}
|
||||
|
||||
CHECK(fclose(file));
|
||||
|
||||
CHECK(unlink(FILENAME));
|
||||
|
||||
exit(exit_code);
|
||||
}
|
||||
END_SETUP()
|
||||
|
|
@ -17,7 +17,7 @@ clone3/clone_parent
|
|||
clone3/clone_process
|
||||
cpu_affinity/cpu_affinity
|
||||
execve/execve
|
||||
execve/execve_multithread
|
||||
execve/execve_mt_parent
|
||||
exit/exit_code
|
||||
exit/exit_procfs
|
||||
eventfd2/eventfd2
|
||||
|
|
|
|||
|
|
@ -1,8 +1,4 @@
|
|||
ProcSelfFd.OpenFd
|
||||
ProcLoadavg.EndsWithNewline
|
||||
ProcLoadavg.Fields
|
||||
ProcPidCmdline.MatchesArgv
|
||||
ProcPidCmdline.SubprocessForkSameCmdline
|
||||
ProcSelfAuxv.EntryPresence
|
||||
ProcSelfAuxv.EntryValues
|
||||
ProcSelfMaps.Basic
|
||||
|
|
@ -14,25 +10,18 @@ ProcSelfFdInfo.GetdentsDuplicates
|
|||
ProcSelfFdInfo.CorrectFds
|
||||
ProcSelfFdInfo.Flags
|
||||
ProcCpuinfo.RequiredFieldsArePresent
|
||||
ProcCpuinfo.DeniesWriteRoot
|
||||
ProcCpuinfo.DeniesWriteNonRoot
|
||||
ProcMeminfo.ContainsBasicFields
|
||||
ProcSelfStat.PopulateWriteRSS
|
||||
ProcSelfStat.PopulateNoneRSS
|
||||
ProcPidStatusTest.HasBasicFields
|
||||
ProcPidStatusTest.StateRunning
|
||||
ProcPidStatusTest.StateSleeping_NoRandomSave
|
||||
ProcPidStatusTest.Threads
|
||||
ProcPidStatTest.VmStats
|
||||
ProcPidEnviron.MatchesEnviron
|
||||
ProcPidSymlink.SubprocessRunning
|
||||
ProcPidSymlink.SubprocessZombied
|
||||
ProcPidSymlink.SubprocessExited
|
||||
ProcPidExe.Subprocess
|
||||
ProcPidFile.SubprocessRunning
|
||||
ProcPidFile.SubprocessZombie
|
||||
ProcPidFile.SubprocessExited
|
||||
ProcTask.KilledThreadsDisappear
|
||||
ProcTask.ChildTaskDir
|
||||
ProcTask.VerifyTaskDir
|
||||
ProcTask.TaskDirCannotBeDeleted
|
||||
|
|
@ -54,4 +43,4 @@ Proc.Statfs
|
|||
SelfAndNumericPid/ProcPidStatTest.HasBasicFields/0
|
||||
SelfAndNumericPid/ProcPidStatTest.HasBasicFields/1
|
||||
SelfAndNumericPid/ProcPidStatmTest.HasBasicFields/0
|
||||
SelfAndNumericPid/ProcPidStatmTest.HasBasicFields/1
|
||||
SelfAndNumericPid/ProcPidStatmTest.HasBasicFields/1
|
||||
|
|
|
|||
Loading…
Reference in New Issue