1 // Copyright 2018 The Fuchsia Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <unittest/unittest.h>
6
7 #include <zircon/process.h>
8 #include <zircon/syscalls.h>
9 #include <zircon/syscalls/object.h>
10
11 // zx_object_get_child(ZX_HANDLE_INVALID) should return
12 // ZX_ERR_BAD_HANDLE. ZX-1702
handle_invalid()13 bool handle_invalid() {
14 zx_handle_t process;
15 zx_status_t status;
16 zx_info_handle_basic_t info;
17 zx_handle_t myself = zx_process_self();
18
19 status = zx_object_get_info(myself, ZX_INFO_HANDLE_BASIC,
20 &info, sizeof(info), NULL, NULL);
21 ASSERT_EQ(status, ZX_OK);
22
23 status = zx_object_get_child(ZX_HANDLE_INVALID, info.koid,
24 ZX_RIGHT_SAME_RIGHTS, &process);
25 ASSERT_EQ(status, ZX_ERR_BAD_HANDLE);
26 return true;
27 }
28
29 BEGIN_TEST_CASE(object_get_child_tests)
30 RUN_TEST(handle_invalid);
END_TEST_CASE(object_get_child_tests)31 END_TEST_CASE(object_get_child_tests)
32
33 #ifndef BUILD_COMBINED_TESTS
34 int main(int argc, char** argv) {
35 return unittest_run_all_tests(argc, argv) ? 0 : -1;
36 }
37 #endif
38