diff --git a/backend.native/tests/build.gradle b/backend.native/tests/build.gradle index a91d9ddff9e..90d1f31bce8 100644 --- a/backend.native/tests/build.gradle +++ b/backend.native/tests/build.gradle @@ -1081,6 +1081,18 @@ kotlinNativeInterop { headers 'sys/stat.h' target 'native' } + + cstdlib { + pkg 'cstdlib' + headers 'stdlib.h' + target 'native' + } + + cstdio { + defFile 'interop/basics/cstdio.def' + target 'native' + compilerOpts '-D_POSIX_SOURCE' // Exclude Darwin extensions causing link errors. + } } task interop0(type: RunInteropKonanTest) { @@ -1088,3 +1100,15 @@ task interop0(type: RunInteropKonanTest) { source = "interop/basics/0.kt" interop = 'sysstat' } + +task interop1(type: RunInteropKonanTest) { + goldValue = "257\n" + source = "interop/basics/1.kt" + interop = 'cstdlib' +} + +task interop2(type: RunInteropKonanTest) { + goldValue = "Hello\n" + source = "interop/basics/2.kt" + interop = 'cstdio' +} diff --git a/backend.native/tests/interop/basics/1.kt b/backend.native/tests/interop/basics/1.kt new file mode 100644 index 00000000000..c25b686f209 --- /dev/null +++ b/backend.native/tests/interop/basics/1.kt @@ -0,0 +1,5 @@ +import cstdlib.* + +fun main(args: Array) { + println(atoi("257")) +} \ No newline at end of file diff --git a/backend.native/tests/interop/basics/2.kt b/backend.native/tests/interop/basics/2.kt new file mode 100644 index 00000000000..cd42c7cf0c8 --- /dev/null +++ b/backend.native/tests/interop/basics/2.kt @@ -0,0 +1,5 @@ +import cstdio.* + +fun main(args: Array) { + puts("Hello") +} \ No newline at end of file diff --git a/backend.native/tests/interop/basics/cstdio.def b/backend.native/tests/interop/basics/cstdio.def new file mode 100644 index 00000000000..9ccc3551c0b --- /dev/null +++ b/backend.native/tests/interop/basics/cstdio.def @@ -0,0 +1,2 @@ +headers = stdio.h +excludedFunctions = _IO_flockfile _IO_funlockfile _IO_ftrylockfile _IO_cleanup_region_start _IO_cleanup_region_end \ No newline at end of file