2 * Copyright 2010 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
9 * Test for getpid syscall.
12 #ifdef USE_RAW_SYSCALLS
13 #include "native_client/src/untrusted/nacl/syscall_bindings_trampoline.h"
15 #include "native_client/tests/syscalls/test.h" //NOLINT
22 #ifdef USE_RAW_SYSCALLS
23 #define GETPID NACL_SYSCALL(getpid)
30 const char *testname = "getpid_test";
31 pid_t pid_one = GETPID();
32 pid_t pid_two = GETPID();
34 // check if it's greater than 0.
35 if ((pid_one > 0) && (pid_one == pid_two)) {
37 test::Passed(testname,
38 "getpid returned what appears to be a valid pid.");
39 } else if (pid_one == pid_two) {
40 // a buffer size that should be sufficient
44 "getpid returned an invalid pid for this test: %d",
47 test_status = test::Failed(testname, buffer, __FILE__, __LINE__);
52 "getpid returned different pids for the same process. First "
53 "time it was called: %d Second time: %d",
57 test_status = test::Failed(testname, buffer, __FILE__, __LINE__);
63 * function testSuite()
65 * Run through a complete sequence of file tests.
67 * returns true if all tests succeed. false if one or more fail.
78 * Runs all tests and calls system exit with appropriate value
79 * 0 - success, all tests passed.
80 * -1 - one or more tests failed.
82 int main(const int argc, const char *argv[]) {
85 // run the full test suite
89 printf("All tests PASSED\n");
92 printf("One or more tests FAILED\n");