Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 65 additions & 6 deletions .github/workflows/bazel_test_centipede.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ jobs:
# TODO(xinhaoyuan): Bump to 24.04 after https://github.com/llvm/llvm-project/issues/102443
# is fixed.
runs-on: ubuntu-22.04
permissions:
contents: read
timeout-minutes: 60
strategy:
matrix:
Expand All @@ -39,13 +41,13 @@ jobs:
run: |
sudo sysctl -w kernel.core_pattern=""
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install -yq \
clang llvm libssl-dev
- name: Restore latest cache
uses: actions/cache/restore@v4
uses: actions/cache/restore@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
with:
path: "~/.cache/bazel"
key: bazel-centipede-cache-${{ matrix.config }}
Expand Down Expand Up @@ -84,19 +86,21 @@ jobs:
bazel test --no//fuzztest:use_riegeli --test_output=errors --linkopt=-fsanitize=address --copt=-fsanitize=address --test_env=ASAN_OPTIONS=detect_leaks=0 --platform_suffix=asan --test_timeout=600 centipede/puzzles:all
- name: Save new cache based on main
if: github.ref == 'refs/heads/main'
uses: actions/cache/save@v4
uses: actions/cache/save@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
with:
path: "~/.cache/bazel"
key: bazel-centipede-cache-${{ matrix.config }}-${{ github.run_id }}
run_tests_mac:
name: Run Centipede tests (MacOS)
runs-on: macos-15
permissions:
contents: read
timeout-minutes: 60
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Restore latest cache
uses: actions/cache/restore@v4
uses: actions/cache/restore@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
with:
path: "~/.cache/bazel"
key: bazel-centipede-cache-mac
Expand Down Expand Up @@ -127,7 +131,62 @@ jobs:
bazel --output_user_root="${HOME}/.cache/bazel" test --test_output=errors --no//fuzztest:use_riegeli --linkopt=-fsanitize=address --copt=-fsanitize=address --test_env=ASAN_OPTIONS=detect_leaks=0 --platform_suffix=asan --test_timeout=600 centipede/puzzles:all
- name: Save new cache based on main
if: github.ref == 'refs/heads/main'
uses: actions/cache/save@v4
uses: actions/cache/save@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
with:
path: "~/.cache/bazel"
key: bazel-centipede-cache-mac-${{ github.run_id }}
run_tests_win:
name: Run Centipede tests (Windows)
runs-on: windows-latest
permissions:
contents: read
timeout-minutes: 60
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Restore latest cache
uses: actions/cache/restore@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
with:
path: "~/.cache/bazel"
key: bazel-centipede-cache-win
restore-keys: bazel-centipede-cache-win-
- name: Set environment variable
run: echo "USE_BAZEL_VERSION=8.7.0" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Run unit tests
if: ${{ !cancelled() }}
run: |
<# Only supported libraries are tested here. #> `
bazelisk test --disk_cache=~/.cache/bazel --local_test_jobs=1 --test_output=errors --no//fuzztest:use_riegeli `
--extra_toolchains=@local_config_cc//:cc-toolchain-x64_windows-clang-cl `
--extra_execution_platforms=//:x64_windows-clang-cl --enable_runfiles -- `
centipede:call_graph_test `
centipede:callstack_test `
centipede:command_test `
centipede:concurrent_bitset_test `
centipede:concurrent_byteset_test `
centipede:config_file_test `
centipede:crash_summary_test `
centipede:execution_metadata_test `
centipede:feature_set_test `
centipede:feature_test `
centipede:foreach_nonzero_test `
centipede:hashed_ring_buffer_test `
centipede:int_utils_test `
centipede:knobs_test `
centipede:mutation_data_test `
centipede:pc_info_test `
centipede:periodic_action_test `
centipede:reverse_pc_table_test `
centipede:rolling_hash_test `
centipede:runner_flags_test `
centipede:runner_result_test `
centipede:rusage_stats_test `
centipede:shared_memory_blob_sequence_test `
centipede:stop_test `
centipede:util_test
- name: Save new cache based on main
if: github.ref == 'refs/heads/main'
uses: actions/cache/save@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
with:
path: "~/.cache/bazel"
key: bazel-centipede-cache-win-${{ github.run_id }}
9 changes: 9 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,12 @@
# limitations under the License.

exports_files(["MODULE.bazel"])

platform(
name = "x64_windows-clang-cl",
constraint_values = [
"@platforms//cpu:x86_64",
"@platforms//os:windows",
"@bazel_tools//tools/cpp:clang-cl",
],
)
4 changes: 4 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ bazel_dep(
name = "rules_cc",
version = "0.2.17",
)

cc_configure = use_extension("@rules_cc//cc:extensions.bzl", "cc_configure_extension")
use_repo(cc_configure, "local_config_cc")

bazel_dep(
name = "rules_shell",
version = "0.6.1",
Expand Down
28 changes: 23 additions & 5 deletions centipede/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ cc_library(
"@com_google_fuzztest//common:hash",
"@com_google_fuzztest//common:logging",
"@com_google_fuzztest//common:remote_file",
"@com_google_fuzztest//common:windows_includes",
],
)

Expand Down Expand Up @@ -296,6 +297,7 @@ cc_library(
"@abseil-cpp//absl/strings:str_format",
"@abseil-cpp//absl/time",
"@com_google_fuzztest//common:logging",
"@com_google_fuzztest//common:windows_includes",
],
)

Expand Down Expand Up @@ -420,8 +422,10 @@ cc_library(
"-lrt", # for shm_open
],
}),
deps = ["@abseil-cpp//absl/base:nullability"],
# don't add any dependencies.
deps = [
"@abseil-cpp//absl/base:nullability",
"@com_google_fuzztest//common:windows_includes",
],
)

cc_library(
Expand Down Expand Up @@ -597,13 +601,17 @@ cc_library(
":stop",
":util",
"@abseil-cpp//absl/base:core_headers",
"@abseil-cpp//absl/cleanup",
"@abseil-cpp//absl/container:btree",
"@abseil-cpp//absl/status",
"@abseil-cpp//absl/status:statusor",
"@abseil-cpp//absl/strings",
"@abseil-cpp//absl/strings:str_format",
"@abseil-cpp//absl/synchronization",
"@abseil-cpp//absl/time",
"@com_google_fuzztest//common:logging",
"@com_google_fuzztest//common:windows_includes",
"@com_google_fuzztest//fuzztest/internal:escaping",
],
)

Expand Down Expand Up @@ -1393,7 +1401,12 @@ cc_test(
cc_test(
name = "util_test",
srcs = ["util_test.cc"],
copts = ["-fno-signed-char"],
copts = select({
"@platforms//os:windows": [
"/J", # Make unsigned char the default
],
"//conditions:default": ["-fno-signed-char"],
}),
deps = [
":feature",
":thread_pool",
Expand Down Expand Up @@ -1558,6 +1571,7 @@ cc_test(
srcs = ["shared_memory_blob_sequence_test.cc"],
deps = [
":shared_memory_blob_sequence",
"@com_google_fuzztest//common:windows_includes",
"@googletest//:gtest_main",
],
)
Expand Down Expand Up @@ -1740,10 +1754,14 @@ cc_binary(
name = "command_test_helper",
srcs = ["command_test_helper.cc"],
deps = [
":runner_fork_server",
"@abseil-cpp//absl/base:nullability",
"@abseil-cpp//absl/strings",
"@abseil-cpp//absl/time",
],
"@com_google_fuzztest//common:windows_includes",
] + select({
"@platforms//os:windows": [],
"//conditions:default": [":runner_fork_server"],
}),
)

cc_test(
Expand Down
7 changes: 4 additions & 3 deletions centipede/analyze_corpora_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ using ::testing::Not;

// Returns path to test_fuzz_target.
static std::string GetTargetPath() {
return GetDataDependencyFilepath("centipede/testing/test_fuzz_target");
return GetDataDependencyFilepath("centipede/testing/test_fuzz_target")
.string();
}

// TODO(ussuri): Implement.
Expand Down Expand Up @@ -91,7 +92,7 @@ TEST(DumpCoverageReport, SimpleCoverageResults) {
auto corpus_records = RunInputsAndCollectCorpusRecords(env, {"func1"});
ASSERT_EQ(corpus_records.size(), 1);

const std::string test_tmpdir = GetTestTempDir(test_info_->name());
const std::string test_tmpdir = GetTestTempDir(test_info_->name()).string();
BinaryInfo binary_info;
binary_info.InitializeFromSanCovBinary(GetTargetPath(), /*env_diff=*/{},
GetObjDumpPath(),
Expand All @@ -100,7 +101,7 @@ TEST(DumpCoverageReport, SimpleCoverageResults) {
GetCoverage(corpus_records, std::move(binary_info));

const std::string coverage_report_path =
std::filesystem::path{test_tmpdir} / "covered_symbol_table";
(std::filesystem::path{test_tmpdir} / "covered_symbol_table").string();
DumpCoverageReport(coverage_results, coverage_report_path);
std::string symbol_table_contents;
ASSERT_OK(RemoteFileGetContents(coverage_report_path, symbol_table_contents));
Expand Down
14 changes: 7 additions & 7 deletions centipede/binary_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void BinaryInfo::InitializeFromSanCovBinary(
":arg3=", EscapeEngineFlag(dso_table_path.path()), ":"));
Command::Options cmd_options;
cmd_options.env_diff = std::move(env_diff);
cmd_options.stdout_file_prefix = log_prefix;
cmd_options.stdout_file_prefix = log_prefix.string();
Command cmd{binary_path_with_args, std::move(cmd_options)};
int exit_code = cmd.Execute();
if (exit_code != EXIT_SUCCESS) {
Expand Down Expand Up @@ -131,40 +131,40 @@ void BinaryInfo::Read(std::string_view dir) {
std::string symbol_table_contents;
// TODO(b/295978603): move calculation of paths into WorkDir class.
FUZZTEST_CHECK_OK(RemoteFileGetContents(
(std::filesystem::path(dir) / kSymbolTableFileName).c_str(),
(std::filesystem::path(dir) / kSymbolTableFileName).string(),
symbol_table_contents));
std::istringstream symbol_table_stream(symbol_table_contents);
symbols.ReadFromLLVMSymbolizer(symbol_table_stream);

std::string pc_table_contents;
FUZZTEST_CHECK_OK(RemoteFileGetContents(
(std::filesystem::path(dir) / kPCTableFileName).c_str(),
(std::filesystem::path(dir) / kPCTableFileName).string(),
pc_table_contents));
std::istringstream pc_table_stream(pc_table_contents);
pc_table = ReadPcTable(pc_table_stream);

cf_table =
ReadCfTable((std::filesystem::path(dir) / kCfTableFileName).c_str());
ReadCfTable((std::filesystem::path(dir) / kCfTableFileName).string());
}

void BinaryInfo::Write(std::string_view dir) {
std::ostringstream symbol_table_stream;
symbols.WriteToLLVMSymbolizer(symbol_table_stream);
// TODO(b/295978603): move calculation of paths into WorkDir class.
FUZZTEST_CHECK_OK(RemoteFileSetContents(
(std::filesystem::path(dir) / kSymbolTableFileName).c_str(),
(std::filesystem::path(dir) / kSymbolTableFileName).string(),
symbol_table_stream.str()));

std::ostringstream pc_table_stream;
WritePcTable(pc_table, pc_table_stream);
FUZZTEST_CHECK_OK(RemoteFileSetContents(
(std::filesystem::path(dir) / kPCTableFileName).c_str(),
(std::filesystem::path(dir) / kPCTableFileName).string(),
pc_table_stream.str()));

std::ostringstream cf_table_stream;
WriteCfTable(cf_table, cf_table_stream);
FUZZTEST_CHECK_OK(RemoteFileSetContents(
(std::filesystem::path(dir) / kCfTableFileName).c_str(),
(std::filesystem::path(dir) / kCfTableFileName).string(),
cf_table_stream.str()));
}

Expand Down
4 changes: 2 additions & 2 deletions centipede/binary_info_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace fuzztest::internal {
namespace {

TEST(BinaryInfoTest, SerializesAndDeserializesBinaryInfoSuccessfully) {
const std::string temp_dir = GetTestTempDir(test_info_->name());
const std::string temp_dir = GetTestTempDir(test_info_->name()).string();

const PCTable input_pcs = {{/*pc=*/0, /*flags=*/1}, {/*pc=*/2, /*flags=*/3}};
std::string input_symbols =
Expand Down Expand Up @@ -57,7 +57,7 @@ TEST(BinaryInfoTest, SerializesAndDeserializesBinaryInfoSuccessfully) {
}

TEST(BinaryInfoTest, SerializesAndDeserializesEmptyBinaryInfoSuccessfully) {
const std::string temp_dir = GetTestTempDir(test_info_->name());
const std::string temp_dir = GetTestTempDir(test_info_->name()).string();

const PCTable input_pcs = {};
std::string input_symbols = "";
Expand Down
2 changes: 1 addition & 1 deletion centipede/blob_file_converter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void Convert( //

FUZZTEST_CHECK(RemotePathExists(in)) << VV(in);
FUZZTEST_CHECK_OK(
RemoteMkdir(std::filesystem::path{out}.parent_path().c_str()));
RemoteMkdir(std::filesystem::path{out}.parent_path().string()));

// Open blob file reader and writer.

Expand Down
Loading
Loading