2 * Copyright (c) 2014 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.
7 #include "native_client/src/include/minsfi.h"
8 #include "native_client/src/include/minsfi_priv.h"
9 #include "native_client/src/include/nacl_assert.h"
11 static int argc_exit_with_syscall = 1;
12 static int argc_exit_with_return = 2;
13 static char *argv[] = { "foo", "bar" };
16 * In this test, the sandboxed code invokes the exit() MinSFI syscall.
17 * We verify that it jumps back to the Invoke function and that it returns
18 * the same status code that the sandbox terminated with.
20 static void test_exit_with_syscall(void) {
23 MinsfiInitializeSandbox();
24 ret_val = MinsfiInvokeSandbox(argc_exit_with_syscall, argv);
25 ASSERT_EQ(ret_val, (int) 0xDEADC0DE);
26 MinsfiDestroySandbox();
30 * In this test, the sandbox does not invoke the exit() syscall, but rather
31 * returns the status code 0xDEADFA11 from the entry function. That is not
32 * a legal way of terminating the sandbox and the Invoke function should report
35 static void test_exit_with_return(void) {
38 MinsfiInitializeSandbox();
39 ret_val = MinsfiInvokeSandbox(argc_exit_with_return, argv);
40 ASSERT_EQ(ret_val, EXIT_FAILURE);
41 MinsfiDestroySandbox();
45 test_exit_with_return();
46 test_exit_with_syscall();