mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
Remove redundant tests
UID/GID is checked in namespace test and open fds in santizier test PiperOrigin-RevId: 510084559 Change-Id: I1aac4d30d44aa2390447f24d228afbb1c3b04e2b
This commit is contained in:
parent
3f53e81d0b
commit
d2dbbbae76
@ -954,7 +954,6 @@ cc_test(
|
|||||||
name = "policybuilder_test",
|
name = "policybuilder_test",
|
||||||
srcs = ["policybuilder_test.cc"],
|
srcs = ["policybuilder_test.cc"],
|
||||||
copts = sapi_platform_copts(),
|
copts = sapi_platform_copts(),
|
||||||
data = ["//sandboxed_api/sandbox2/testcases:print_fds"],
|
|
||||||
tags = [
|
tags = [
|
||||||
"no_qemu_user_mode",
|
"no_qemu_user_mode",
|
||||||
"requires-net:external",
|
"requires-net:external",
|
||||||
|
@ -1044,9 +1044,6 @@ if(BUILD_TESTING AND SAPI_BUILD_TESTING)
|
|||||||
set_target_properties(sandbox2_policybuilder_test PROPERTIES
|
set_target_properties(sandbox2_policybuilder_test PROPERTIES
|
||||||
OUTPUT_NAME policybuilder_test
|
OUTPUT_NAME policybuilder_test
|
||||||
)
|
)
|
||||||
add_dependencies(sandbox2_policybuilder_test
|
|
||||||
sandbox2::testcase_print_fds
|
|
||||||
)
|
|
||||||
target_link_libraries(sandbox2_policybuilder_test
|
target_link_libraries(sandbox2_policybuilder_test
|
||||||
PRIVATE absl::strings
|
PRIVATE absl::strings
|
||||||
sandbox2::bpf_helper
|
sandbox2::bpf_helper
|
||||||
|
@ -58,14 +58,12 @@ class PolicyBuilderPeer {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
using ::sapi::GetTestSourcePath;
|
|
||||||
using ::testing::AllOf;
|
using ::testing::AllOf;
|
||||||
using ::testing::AnyOf;
|
using ::testing::AnyOf;
|
||||||
using ::testing::Eq;
|
using ::testing::Eq;
|
||||||
using ::testing::Gt;
|
using ::testing::Gt;
|
||||||
using ::testing::HasSubstr;
|
using ::testing::HasSubstr;
|
||||||
using ::testing::Lt;
|
using ::testing::Lt;
|
||||||
using ::testing::NotNull;
|
|
||||||
using ::testing::StartsWith;
|
using ::testing::StartsWith;
|
||||||
using ::testing::StrEq;
|
using ::testing::StrEq;
|
||||||
using ::sapi::IsOk;
|
using ::sapi::IsOk;
|
||||||
@ -253,30 +251,5 @@ TEST_F(PolicyBuilderTest, TestInterfacesNetwork) {
|
|||||||
EXPECT_THAT(count, Gt(1));
|
EXPECT_THAT(count, Gt(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(PolicyBuilderTest, TestUid) {
|
|
||||||
if constexpr (!sapi::host_os::IsAndroid()) {
|
|
||||||
EXPECT_THAT(Run({"/usr/bin/id", "-u"}), StrEq("1000\n"));
|
|
||||||
} else {
|
|
||||||
EXPECT_THAT(Run({"/bin/id", "-u"}), StrEq("0\n"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(PolicyBuilderTest, TestGid) {
|
|
||||||
if constexpr (!sapi::host_os::IsAndroid()) {
|
|
||||||
EXPECT_THAT(Run({"/usr/bin/id", "-g"}), StrEq("1000\n"));
|
|
||||||
} else {
|
|
||||||
EXPECT_THAT(Run({"/bin/id", "-g"}), StrEq("0\n"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(PolicyBuilderTest, TestOpenFds) {
|
|
||||||
SKIP_SANITIZERS_AND_COVERAGE;
|
|
||||||
|
|
||||||
std::string sandboxee = GetTestSourcePath("sandbox2/testcases/print_fds");
|
|
||||||
std::string expected =
|
|
||||||
absl::StrCat("0\n1\n2\n", sandbox2::Comms::kSandbox2ClientCommsFD, "\n");
|
|
||||||
EXPECT_THAT(Run({sandboxee}), StrEq(expected));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace sandbox2
|
} // namespace sandbox2
|
||||||
|
@ -130,13 +130,6 @@ cc_binary(
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
cc_binary(
|
|
||||||
name = "print_fds",
|
|
||||||
testonly = True,
|
|
||||||
srcs = ["print_fds.cc"],
|
|
||||||
copts = sapi_platform_copts(),
|
|
||||||
)
|
|
||||||
|
|
||||||
cc_binary(
|
cc_binary(
|
||||||
name = "sanitizer",
|
name = "sanitizer",
|
||||||
testonly = True,
|
testonly = True,
|
||||||
|
@ -152,18 +152,6 @@ target_link_libraries(sandbox2_testcase_policy PRIVATE
|
|||||||
sapi::config
|
sapi::config
|
||||||
)
|
)
|
||||||
|
|
||||||
# sandboxed_api/sandbox2/testcases:print_fds
|
|
||||||
add_executable(sandbox2_testcase_print_fds
|
|
||||||
print_fds.cc
|
|
||||||
)
|
|
||||||
add_executable(sandbox2::testcase_print_fds ALIAS sandbox2_testcase_print_fds)
|
|
||||||
set_target_properties(sandbox2_testcase_print_fds PROPERTIES
|
|
||||||
OUTPUT_NAME print_fds
|
|
||||||
)
|
|
||||||
target_link_libraries(sandbox2_testcase_print_fds PRIVATE
|
|
||||||
sapi::base
|
|
||||||
)
|
|
||||||
|
|
||||||
# sandboxed_api/sandbox2/testcases:sanitizer
|
# sandboxed_api/sandbox2/testcases:sanitizer
|
||||||
add_executable(sandbox2_testcase_sanitizer
|
add_executable(sandbox2_testcase_sanitizer
|
||||||
sanitizer.cc
|
sanitizer.cc
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
// Copyright 2019 Google LLC
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
// A binary that prints its opened file descriptors.
|
|
||||||
|
|
||||||
#include <fcntl.h>
|
|
||||||
|
|
||||||
#include <cstdio>
|
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
|
||||||
for (int fd = 0; fd < 4096; fd++) {
|
|
||||||
if (fcntl(fd, F_GETFD) != -1) {
|
|
||||||
printf("%d\n", fd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user