[flang] Fix length handling in character kind implicit conversion (#74586)
[llvm-project.git] / libc / test / integration / src / unistd / execv_test.cpp
blob254ef955f2720e08b81cc6f35c1de8fa1d5f704a
1 //===-- Unittests for execv -----------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "src/sys/wait/waitpid.h"
10 #include "src/unistd/execv.h"
11 #include "src/unistd/fork.h"
13 #include "test/IntegrationTest/test.h"
15 #include <signal.h>
16 #include <sys/wait.h>
18 void fork_and_execv_normal_exit() {
19 pid_t pid = LIBC_NAMESPACE::fork();
20 if (pid == 0) {
21 const char *path = "libc_execv_test_normal_exit";
22 char *const argv[] = {
23 const_cast<char *>("execv_test_normal_exit"),
24 nullptr,
26 LIBC_NAMESPACE::execv(path, argv);
28 ASSERT_TRUE(pid > 0);
29 int status;
30 pid_t cpid = LIBC_NAMESPACE::waitpid(pid, &status, 0);
31 ASSERT_TRUE(cpid > 0);
32 ASSERT_EQ(cpid, pid);
33 ASSERT_TRUE(WIFEXITED(status));
36 void fork_and_execv_signal_exit() {
37 pid_t pid = LIBC_NAMESPACE::fork();
38 if (pid == 0) {
39 const char *path = "libc_execv_test_signal_exit";
40 char *const argv[] = {
41 const_cast<char *>("execv_test_normal_exit"),
42 nullptr,
44 LIBC_NAMESPACE::execv(path, argv);
46 ASSERT_TRUE(pid > 0);
47 int status;
48 pid_t cpid = LIBC_NAMESPACE::waitpid(pid, &status, 0);
49 ASSERT_TRUE(cpid > 0);
50 ASSERT_EQ(cpid, pid);
51 ASSERT_FALSE(WIFEXITED(status));
52 ASSERT_TRUE(WTERMSIG(status) == SIGUSR1);
55 TEST_MAIN(int argc, char **argv, char **envp) {
56 fork_and_execv_normal_exit();
57 fork_and_execv_signal_exit();
58 return 0;