[test_runner] Add handle test suite

For now this just tests handle cloning and basic capability checking.
This commit is contained in:
Justin C. Miller
2022-02-22 00:06:42 -08:00
parent 30aed15090
commit 69a3b6dad7
4 changed files with 31 additions and 2 deletions

View File

@@ -4,6 +4,8 @@
/// \file caps.h
/// Capability bitfield constants
#define j6_handle_caps(h) (((h)>>32) & 0xffffff)
/*[[[cog code generation
from definitions.context import Context

View File

@@ -9,6 +9,7 @@ module("test_runner",
"test_case.cpp",
"tests/constexpr_hash.cpp",
"tests/handles.cpp",
"tests/linked_list.cpp",
"tests/mailbox.cpp",
"tests/map.cpp",

View File

@@ -0,0 +1,26 @@
#include <j6/caps.h>
#include <j6/errors.h>
#include <j6/syscalls.h>
#include <j6/types.h>
#include "test_case.h"
extern j6_handle_t __handle_self;
struct handle_tests :
public test::fixture
{
};
TEST_CASE( handle_tests, clone_cap )
{
j6_status_t s;
j6_handle_t self0 = __handle_self;
j6_handle_t self1 = j6_handle_invalid;
s = j6_handle_clone(self0, &self1, j6_handle_caps(self0) & ~j6_cap_object_clone);
CHECK( s == j6_status_ok, "Cloning self handle" );
j6_handle_t self2 = j6_handle_invalid;
s = j6_handle_clone(self1, &self2, j6_handle_caps(self1));
CHECK( s == j6_err_denied, "Cloning non-clonable handle" );
}

View File

@@ -28,7 +28,7 @@ TEST_CASE( mailbox_tests, would_block )
size_t buffer_size = 128;
j6_handle_t handles[10];
size_t handle_count = 10;
uint64_t reply_tag = 0;
uint16_t reply_tag = 0;
uint64_t badge = 0;
uint64_t flags = 0;
@@ -66,7 +66,7 @@ TEST_CASE( mailbox_tests, send_receive )
size_t in_buffer_size = 128;
j6_handle_t in_handles[10];
size_t in_handle_count = 10;
uint64_t in_reply_tag = 0;
uint16_t in_reply_tag = 0;
uint64_t in_badge = 0;
uint64_t in_flags = 0;