mirror of
https://github.com/ohwgiles/laminar.git
synced 2024-10-27 20:34:20 +00:00
test: fix RunTest on systems with single file core utilities (#95)
On systems such as Alpine Linux (with busybox) and Adelie Linux (with coreutils), the shell core utilities such as pwd, true, false, env, and yes are all symlinks to a single binary. This single binary relies on the name of the symlink to determine which command ("applet" in busybox parlance) to execute. Therefore creating symlinks to these symlinks will not work since the single binary will only see the top-level symlink and thus think it is an invalid command. Instead, generate executable shell scripts that exec into the desired command. This also allows $PATH based resolution to occur instead of hard-coding the command paths. See also issue #94.
This commit is contained in:
parent
448d8cfa48
commit
1642899159
@ -69,12 +69,15 @@ protected:
|
|||||||
class Run run;
|
class Run run;
|
||||||
|
|
||||||
void setRunLink(const char * path) {
|
void setRunLink(const char * path) {
|
||||||
tmp.fs->symlink(kj::Path{"cfg","jobs",run.name+".run"}, path, kj::WriteMode::CREATE|kj::WriteMode::CREATE_PARENT|kj::WriteMode::EXECUTABLE);
|
KJ_IF_MAYBE(f, tmp.fs->tryOpenFile(kj::Path{"cfg", "jobs", run.name + ".run"},
|
||||||
|
kj::WriteMode::CREATE | kj::WriteMode::CREATE_PARENT | kj::WriteMode::EXECUTABLE)) {
|
||||||
|
(f->get())->writeAll(std::string("#!/bin/sh\nexec ") + path + "\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(RunTest, WorkingDirectory) {
|
TEST_F(RunTest, WorkingDirectory) {
|
||||||
setRunLink("/bin/pwd");
|
setRunLink("pwd");
|
||||||
run.configure(1, node, *tmp.fs);
|
run.configure(1, node, *tmp.fs);
|
||||||
runAll();
|
runAll();
|
||||||
std::string cwd{tmp.path.append(kj::Path{"run","foo","1"}).toString(true).cStr()};
|
std::string cwd{tmp.path.append(kj::Path{"run","foo","1"}).toString(true).cStr()};
|
||||||
@ -82,21 +85,21 @@ TEST_F(RunTest, WorkingDirectory) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(RunTest, SuccessStatus) {
|
TEST_F(RunTest, SuccessStatus) {
|
||||||
setRunLink("/bin/true");
|
setRunLink("true");
|
||||||
run.configure(1, node, *tmp.fs);
|
run.configure(1, node, *tmp.fs);
|
||||||
runAll();
|
runAll();
|
||||||
EXPECT_EQ(RunState::SUCCESS, run.result);
|
EXPECT_EQ(RunState::SUCCESS, run.result);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(RunTest, FailedStatus) {
|
TEST_F(RunTest, FailedStatus) {
|
||||||
setRunLink("/bin/false");
|
setRunLink("false");
|
||||||
run.configure(1, node, *tmp.fs);
|
run.configure(1, node, *tmp.fs);
|
||||||
runAll();
|
runAll();
|
||||||
EXPECT_EQ(RunState::FAILED, run.result);
|
EXPECT_EQ(RunState::FAILED, run.result);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(RunTest, Environment) {
|
TEST_F(RunTest, Environment) {
|
||||||
setRunLink("/usr/bin/env");
|
setRunLink("env");
|
||||||
run.configure(1234, node, *tmp.fs);
|
run.configure(1234, node, *tmp.fs);
|
||||||
runAll();
|
runAll();
|
||||||
|
|
||||||
@ -113,7 +116,7 @@ TEST_F(RunTest, Environment) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(RunTest, ParamsToEnv) {
|
TEST_F(RunTest, ParamsToEnv) {
|
||||||
setRunLink("/usr/bin/env");
|
setRunLink("env");
|
||||||
run.params["foo"] = "bar";
|
run.params["foo"] = "bar";
|
||||||
run.configure(1, node, *tmp.fs);
|
run.configure(1, node, *tmp.fs);
|
||||||
runAll();
|
runAll();
|
||||||
@ -122,7 +125,7 @@ TEST_F(RunTest, ParamsToEnv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(RunTest, Abort) {
|
TEST_F(RunTest, Abort) {
|
||||||
setRunLink("/usr/bin/yes");
|
setRunLink("yes");
|
||||||
run.configure(1, node, *tmp.fs);
|
run.configure(1, node, *tmp.fs);
|
||||||
run.step();
|
run.step();
|
||||||
usleep(200); // TODO fix
|
usleep(200); // TODO fix
|
||||||
|
Loading…
Reference in New Issue
Block a user