forked from dotnet/runtimelab
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update runtime tests to work with WASIp2
As of this writing, WASIp2 [does not support process exit statuses](WebAssembly/wasi-cli#11) beyond 0 (success) and 1 (failure). To work around this, I've modified the relevant tests to return 0 on success instead of 100. Signed-off-by: Joel Dice <[email protected]>
- Loading branch information
Showing
39 changed files
with
347 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,4 +72,5 @@ | |
throw new Exception(); | ||
#endif | ||
|
||
return 100; | ||
return 0; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
167 changes: 167 additions & 0 deletions
167
src/tests/nativeaot/SmokeTests/SharedLibrary/Library.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
// Generated by `wit-bindgen` 0.26.0. DO NOT EDIT! | ||
// <auto-generated /> | ||
#nullable enable | ||
using System; | ||
using System.Runtime.CompilerServices; | ||
using System.Collections; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Diagnostics.CodeAnalysis; | ||
|
||
namespace LibraryWorld { | ||
|
||
public interface ILibraryWorld { | ||
static abstract int ReturnsPrimitiveInt(); | ||
|
||
static abstract bool ReturnsPrimitiveBool(); | ||
|
||
static abstract uint ReturnsPrimitiveChar(); | ||
|
||
static abstract void EnsureManagedClassLoaders(); | ||
|
||
static abstract int CheckSimpleExceptionHandling(); | ||
|
||
static abstract int CheckSimpleGcCollect(); | ||
|
||
} | ||
|
||
public readonly struct None {} | ||
|
||
[StructLayout(LayoutKind.Sequential)] | ||
public readonly struct Result<Ok, Err> | ||
{ | ||
public readonly byte Tag; | ||
private readonly object value; | ||
|
||
private Result(byte tag, object value) | ||
{ | ||
Tag = tag; | ||
this.value = value; | ||
} | ||
|
||
public static Result<Ok, Err> ok(Ok ok) | ||
{ | ||
return new Result<Ok, Err>(OK, ok!); | ||
} | ||
|
||
public static Result<Ok, Err> err(Err err) | ||
{ | ||
return new Result<Ok, Err>(ERR, err!); | ||
} | ||
|
||
public bool IsOk => Tag == OK; | ||
public bool IsErr => Tag == ERR; | ||
|
||
public Ok AsOk | ||
{ | ||
get | ||
{ | ||
if (Tag == OK) | ||
return (Ok)value; | ||
else | ||
throw new ArgumentException("expected OK, got " + Tag); | ||
} | ||
} | ||
|
||
public Err AsErr | ||
{ | ||
get | ||
{ | ||
if (Tag == ERR) | ||
return (Err)value; | ||
else | ||
throw new ArgumentException("expected ERR, got " + Tag); | ||
} | ||
} | ||
|
||
public const byte OK = 0; | ||
public const byte ERR = 1; | ||
} | ||
|
||
namespace exports { | ||
public static class LibraryWorld | ||
{ | ||
|
||
[UnmanagedCallersOnly(EntryPoint = "returns-primitive-int")] | ||
public static unsafe int wasmExportReturnsPrimitiveInt() { | ||
|
||
int ret; | ||
ret = LibraryWorldImpl.ReturnsPrimitiveInt(); | ||
return ret; | ||
|
||
} | ||
|
||
[UnmanagedCallersOnly(EntryPoint = "cabi_post_returns-primitive-int")] | ||
public static void cabi_post_wasmExportReturnsPrimitiveInt(int returnValue) { | ||
Console.WriteLine("TODO: cabi_post_returns-primitive-int"); | ||
} | ||
|
||
[UnmanagedCallersOnly(EntryPoint = "returns-primitive-bool")] | ||
public static unsafe int wasmExportReturnsPrimitiveBool() { | ||
|
||
bool ret; | ||
ret = LibraryWorldImpl.ReturnsPrimitiveBool(); | ||
return (ret ? 1 : 0); | ||
|
||
} | ||
|
||
[UnmanagedCallersOnly(EntryPoint = "cabi_post_returns-primitive-bool")] | ||
public static void cabi_post_wasmExportReturnsPrimitiveBool(int returnValue) { | ||
Console.WriteLine("TODO: cabi_post_returns-primitive-bool"); | ||
} | ||
|
||
[UnmanagedCallersOnly(EntryPoint = "returns-primitive-char")] | ||
public static unsafe int wasmExportReturnsPrimitiveChar() { | ||
|
||
uint ret; | ||
ret = LibraryWorldImpl.ReturnsPrimitiveChar(); | ||
return ((int)ret); | ||
|
||
} | ||
|
||
[UnmanagedCallersOnly(EntryPoint = "cabi_post_returns-primitive-char")] | ||
public static void cabi_post_wasmExportReturnsPrimitiveChar(int returnValue) { | ||
Console.WriteLine("TODO: cabi_post_returns-primitive-char"); | ||
} | ||
|
||
[UnmanagedCallersOnly(EntryPoint = "ensure-managed-class-loaders")] | ||
public static unsafe void wasmExportEnsureManagedClassLoaders() { | ||
|
||
LibraryWorldImpl.EnsureManagedClassLoaders(); | ||
|
||
} | ||
|
||
[UnmanagedCallersOnly(EntryPoint = "check-simple-exception-handling")] | ||
public static unsafe int wasmExportCheckSimpleExceptionHandling() { | ||
|
||
int ret; | ||
ret = LibraryWorldImpl.CheckSimpleExceptionHandling(); | ||
return ret; | ||
|
||
} | ||
|
||
[UnmanagedCallersOnly(EntryPoint = "cabi_post_check-simple-exception-handling")] | ||
public static void cabi_post_wasmExportCheckSimpleExceptionHandling(int returnValue) { | ||
Console.WriteLine("TODO: cabi_post_check-simple-exception-handling"); | ||
} | ||
|
||
[UnmanagedCallersOnly(EntryPoint = "check-simple-gc-collect")] | ||
public static unsafe int wasmExportCheckSimpleGcCollect() { | ||
|
||
int ret; | ||
ret = LibraryWorldImpl.CheckSimpleGcCollect(); | ||
return ret; | ||
|
||
} | ||
|
||
[UnmanagedCallersOnly(EntryPoint = "cabi_post_check-simple-gc-collect")] | ||
public static void cabi_post_wasmExportCheckSimpleGcCollect(int returnValue) { | ||
Console.WriteLine("TODO: cabi_post_check-simple-gc-collect"); | ||
} | ||
|
||
} | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
src/tests/nativeaot/SmokeTests/SharedLibrary/LibraryWorld_cabi_realloc.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <stdlib.h> | ||
|
||
/* Done in C so we can avoid initializing the dotnet runtime and hence WASI libc */ | ||
/* It would be preferable to do this in C# but the constraints of cabi_realloc and the demands */ | ||
/* of WASI libc prevent us doing so. */ | ||
/* See https://github.com/bytecodealliance/wit-bindgen/issues/777 */ | ||
/* and https://github.com/WebAssembly/wasi-libc/issues/452 */ | ||
/* The component model `start` function might be an alternative to this depending on whether it */ | ||
/* has the same constraints as `cabi_realloc` */ | ||
__attribute__((__weak__, __export_name__("cabi_realloc"))) | ||
void *cabi_realloc(void *ptr, size_t old_size, size_t align, size_t new_size) { | ||
(void) old_size; | ||
if (new_size == 0) return (void*) align; | ||
void *ret = realloc(ptr, new_size); | ||
if (!ret) abort(); | ||
return ret; | ||
} |
Binary file added
BIN
+661 Bytes
src/tests/nativeaot/SmokeTests/SharedLibrary/LibraryWorld_cabi_realloc.o
Binary file not shown.
Binary file added
BIN
+464 Bytes
src/tests/nativeaot/SmokeTests/SharedLibrary/LibraryWorld_component_type.o
Binary file not shown.
Oops, something went wrong.