Fix various issues in libpkl (#1805)
* Fix possible SIGSEGV from host process. - Require that the same `pkl_exec_t` be used in the same OS thread; returning meaningful error if this fails * Remove `System.exitProcess(1)` logic in NativeTransport; this would kill the host process too and isn't an appropriate action for a received ProtocolException * Allow multiple calls to pkl_init without pkl_close; this limitation doesn't really make any sense * Prefer calling methods defined in graal_isolate.h, instead of creating the same method via CEntryPoint * Add a CMakeLists.txt so that CLion can follow the code and provide proper diagnostics * Improve doc comments; describe params as either in or out
This commit is contained in:
1 parent
5333d55269
commit
417c08ae11
10 files changed
+169
-188
No files matched your search
@@ -77,6 +77,20 @@ void test_empty_message() {
|
||||
printf("✓ Empty message rejected\n");
|
||||
}
|
||||
|
||||
void test_garbage_send_message() {
|
||||
pkl_error_t err = { 0 };
|
||||
pkl_exec_t *exec = NULL;
|
||||
assert(pkl_init(test_message_handler, NULL, &exec, &err) == 0);
|
||||
|
||||
char *message = (char*) (unsigned char[] ) { 0x41, 0x42, 0x43 };
|
||||
int result = pkl_send_message(exec, 3, message, &err);
|
||||
assert(result == PKL_ERR_PROTOCOL);
|
||||
|
||||
result = pkl_close(exec, &err);
|
||||
assert(result == 0);
|
||||
printf("✓ Garbage message becomes protocol exception\n");
|
||||
}
|
||||
|
||||
int main() {
|
||||
printf("Running libpkl C tests...\n\n");
|
||||
|
||||
@@ -84,6 +98,7 @@ int main() {
|
||||
test_init_close();
|
||||
test_null_send_message();
|
||||
test_empty_message();
|
||||
test_garbage_send_message();
|
||||
|
||||
printf("\nAll tests passed!\n");
|
||||
return 0;
|
||||
|
||||
Reference in new issue
Block a user