-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest.php
More file actions
47 lines (40 loc) · 1.12 KB
/
test.php
File metadata and controls
47 lines (40 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
chdir("examples");
$sun = defined("PHP_WINDOWS_VERSION_MAJOR") ? "..\\..\\Sun.exe" : "../../suncli";
function toexe($filename) {
if (defined("PHP_WINDOWS_VERSION_MAJOR")) {
return $filename/*.".exe"*/;
}
$env = (PHP_OS_FAMILY === "Darwin") ? "DYLD_LIBRARY_PATH" : "LD_LIBRARY_PATH";
return "$env=.:\$$env ./" . $filename;
}
function assert_equal($got, $expected) {
if ($got !== $expected) {
throw new Exception("Expected $expected but got $got");
}
}
chdir("dll");
passthru($sun);
if (defined("PHP_WINDOWS_VERSION_MAJOR")) {
copy("foolib/foolib.dll", "foolib.dll");
}
elseif (PHP_OS_FAMILY === "Darwin") {
copy("foolib/libfoolib.dylib", "libfoolib.dylib");
}
else {
copy("foolib/libfoolib.so", "libfoolib.so");
}
assert_equal(shell_exec(toexe("consumer")), "Hello, world!\n");
chdir("..");
chdir("exe");
passthru($sun);
assert_equal(shell_exec(toexe("exe")), "Hello, world!\n");
chdir("..");
chdir("exe-lib");
passthru($sun);
assert_equal(shell_exec(toexe("exe-lib")), "Hello, world!\n");
chdir("..");
chdir("subdirs");
passthru($sun);
assert_equal(shell_exec(toexe("dont_do_this")), "Hello, world!\n");
chdir("..");