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:
Wiktor Garbacz 2023-02-16 02:27:57 -08:00 committed by Copybara-Service
parent 3f53e81d0b
commit d2dbbbae76
6 changed files with 0 additions and 77 deletions

View File

@ -954,7 +954,6 @@ cc_test(
name = "policybuilder_test",
srcs = ["policybuilder_test.cc"],
copts = sapi_platform_copts(),
data = ["//sandboxed_api/sandbox2/testcases:print_fds"],
tags = [
"no_qemu_user_mode",
"requires-net:external",

View File

@ -1044,9 +1044,6 @@ if(BUILD_TESTING AND SAPI_BUILD_TESTING)
set_target_properties(sandbox2_policybuilder_test PROPERTIES
OUTPUT_NAME policybuilder_test
)
add_dependencies(sandbox2_policybuilder_test
sandbox2::testcase_print_fds
)
target_link_libraries(sandbox2_policybuilder_test
PRIVATE absl::strings
sandbox2::bpf_helper

View File

@ -58,14 +58,12 @@ class PolicyBuilderPeer {
namespace {
using ::sapi::GetTestSourcePath;
using ::testing::AllOf;
using ::testing::AnyOf;
using ::testing::Eq;
using ::testing::Gt;
using ::testing::HasSubstr;
using ::testing::Lt;
using ::testing::NotNull;
using ::testing::StartsWith;
using ::testing::StrEq;
using ::sapi::IsOk;
@ -253,30 +251,5 @@ TEST_F(PolicyBuilderTest, TestInterfacesNetwork) {
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 sandbox2

View File

@ -130,13 +130,6 @@ cc_binary(
],
)
cc_binary(
name = "print_fds",
testonly = True,
srcs = ["print_fds.cc"],
copts = sapi_platform_copts(),
)
cc_binary(
name = "sanitizer",
testonly = True,

View File

@ -152,18 +152,6 @@ target_link_libraries(sandbox2_testcase_policy PRIVATE
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
add_executable(sandbox2_testcase_sanitizer
sanitizer.cc

View File

@ -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);
}
}
}