mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
Jsonnet: Update with latest Sandboxed API changes
This fixes some build issues due to changes in Sandboxed API and upstream Jsonnet. PiperOrigin-RevId: 423787176 Change-Id: Ia3b9eab6b96e2fca70531f998e441ace04f31e3e
This commit is contained in:
parent
e4436c87e8
commit
7afaaa7c6a
|
@ -32,17 +32,18 @@ add_subdirectory("${SAPI_ROOT}"
|
|||
EXCLUDE_FROM_ALL)
|
||||
|
||||
add_sapi_library(jsonnet_sapi
|
||||
FUNCTIONS c_jsonnet_evaluate_snippet
|
||||
c_jsonnet_make
|
||||
FUNCTIONS c_free_input
|
||||
c_jsonnet_destroy
|
||||
c_read_input
|
||||
c_write_output_file
|
||||
c_jsonnet_realloc
|
||||
c_jsonnet_evaluate_snippet
|
||||
c_jsonnet_evaluate_snippet_multi
|
||||
c_write_multi_output_files
|
||||
c_write_output_stream
|
||||
c_jsonnet_evaluate_snippet_stream
|
||||
c_jsonnet_fmt_snippet
|
||||
c_jsonnet_make
|
||||
c_jsonnet_realloc
|
||||
c_read_input
|
||||
c_write_multi_output_files
|
||||
c_write_output_file
|
||||
c_write_output_stream
|
||||
INPUTS jsonnet_helper.h
|
||||
LIBRARY jsonnet_helper
|
||||
LIBRARY_NAME Jsonnet
|
||||
|
|
|
@ -28,7 +28,7 @@ absl::Status JsonnetTransaction::Main() {
|
|||
sapi::v::RemotePtr vm_pointer(jsonnet_vm);
|
||||
|
||||
// Read input file.
|
||||
std::string in_file_in_sandboxee(JoinPath("/input", Basename(in_file)));
|
||||
std::string in_file_in_sandboxee(JoinPath("/input", Basename(in_file_)));
|
||||
sapi::v::ConstCStr in_file_var(in_file_in_sandboxee.c_str());
|
||||
SAPI_ASSIGN_OR_RETURN(char* input,
|
||||
api.c_read_input(false, in_file_var.PtrBefore()));
|
||||
|
@ -43,7 +43,7 @@ absl::Status JsonnetTransaction::Main() {
|
|||
"Jsonnet code evaluation failed.");
|
||||
|
||||
// Write data to file.
|
||||
std::string out_file_in_sandboxee(JoinPath("/output", Basename(out_file)));
|
||||
std::string out_file_in_sandboxee(JoinPath("/output", Basename(out_file_)));
|
||||
sapi::v::ConstCStr out_file_var(out_file_in_sandboxee.c_str());
|
||||
sapi::v::RemotePtr output_pointer(output);
|
||||
SAPI_ASSIGN_OR_RETURN(
|
||||
|
|
|
@ -44,8 +44,7 @@ class JsonnetSapiSandbox : public JsonnetSandbox {
|
|||
__NR_futex,
|
||||
__NR_close,
|
||||
})
|
||||
.AddDirectoryAt(sandbox2::file::CleanPath(&out_directory_[0]),
|
||||
"/output",
|
||||
.AddDirectoryAt(sapi::file::CleanPath(&out_directory_[0]), "/output",
|
||||
/*is_ro=*/false)
|
||||
.AddDirectoryAt(dirname(&in_file_[0]), "/input", true)
|
||||
.BuildOrDie();
|
||||
|
|
|
@ -35,7 +35,7 @@ TEST_F(JsonnetTest, One_file_no_dependencies) {
|
|||
constexpr char kOutputToRead[] = "tests_output/arith_output";
|
||||
constexpr char kOutputToExpect[] = "tests_expected_output/arith.golden";
|
||||
|
||||
Read_input(kInputFile);
|
||||
ReadInput(kInputFile);
|
||||
EvaluateJsonnetCode(kBase, true);
|
||||
WriteOutput(kOutputFile, kBase);
|
||||
|
||||
|
@ -56,8 +56,8 @@ TEST_F(JsonnetTest, One_file_some_dependencies) {
|
|||
EvaluateJsonnetCode(kBase, true);
|
||||
WriteOutput(kOutputFile, kBase);
|
||||
|
||||
const std::string produced_output = Read_output(kOutputToRead);
|
||||
const std::string expected_output = Read_output(kOutputToExpect);
|
||||
const std::string produced_output = ReadOutput(kOutputToRead);
|
||||
const std::string expected_output = ReadOutput(kOutputToExpect);
|
||||
|
||||
ASSERT_STREQ(produced_output.c_str(), expected_output.c_str());
|
||||
}
|
||||
|
|
|
@ -22,13 +22,13 @@ void JsonnetTestHelper::TestSetUp() {
|
|||
ASSERT_GE(error, 0);
|
||||
|
||||
std::pair<absl::string_view, absl::string_view> parts_of_path =
|
||||
sandbox2::file::SplitPath(buffer);
|
||||
sapi::file::SplitPath(buffer);
|
||||
absl::string_view binary_path = parts_of_path.first;
|
||||
|
||||
std::string input_path =
|
||||
sandbox2::file::JoinPath(binary_path, "tests_input", "dummy_input");
|
||||
sapi::file::JoinPath(binary_path, "tests_input", "dummy_input");
|
||||
std::string output_path =
|
||||
sandbox2::file::JoinPath(binary_path, "tests_output", "dummy_input");
|
||||
sapi::file::JoinPath(binary_path, "tests_output", "dummy_input");
|
||||
|
||||
// Set up sandbox and api.
|
||||
sandbox_ = absl::make_unique<JsonnetBaseSandbox>(input_path, output_path);
|
||||
|
@ -70,7 +70,7 @@ void JsonnetTestHelper::ReadInput(const char* filename) {
|
|||
}
|
||||
|
||||
// Evaluates jsonnet code.
|
||||
void JsonnetTestHelper::Evaluate_jsonnet_code(Evaluation type,
|
||||
void JsonnetTestHelper::EvaluateJsonnetCode(Evaluation type,
|
||||
bool expected_correct) {
|
||||
sapi::v::ConstCStr in_file_var(input_filename_in_sandboxee_.c_str());
|
||||
sapi::v::Int error;
|
||||
|
|
Loading…
Reference in New Issue
Block a user