mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-27 11:07:33 +03:00
feat: enable prof integration tests
Refactor prof flag test changes and handle source inclusion. This enables prof tests for all integration tests.
This commit is contained in:
parent
48e68dfc84
commit
8b561971c4
5 changed files with 195 additions and 38 deletions
|
|
@ -1,34 +1,19 @@
|
|||
load("@rules_cc//cc:defs.bzl", "cc_test")
|
||||
load("//tools:cc.bzl", "COPTS")
|
||||
load("//tools:test.bzl", "join_conf", "test_name")
|
||||
load("//tools:transition.bzl", "PLATFORM", "transition_default_constraints")
|
||||
|
||||
exports_files(
|
||||
[
|
||||
"arena_reset.c",
|
||||
"batch_alloc.c",
|
||||
],
|
||||
visibility = ["//:__subpackages__"],
|
||||
)
|
||||
|
||||
UNIT_TESTS = [
|
||||
{"src": "a0.c"},
|
||||
{
|
||||
"src": "arena_decay.c",
|
||||
"conf": "dirty_decay_ms:1000,muzzy_decay_ms:1000,tcache_max:1024",
|
||||
},
|
||||
{
|
||||
"src": "arena_reset_prof.c",
|
||||
"conf": "prof:true,lg_prof_sample:0",
|
||||
},
|
||||
{"src": "arena_reset.c"},
|
||||
{"src": "atomic.c"},
|
||||
{"src": "background_thread.c"},
|
||||
{"src": "background_thread_enable.c"},
|
||||
{"src": "base.c"},
|
||||
{
|
||||
"src": "batch_alloc_prof.c",
|
||||
"conf": "prof:true,lg_prof_sample:14",
|
||||
},
|
||||
{
|
||||
"src": "batch_alloc.c",
|
||||
"conf": "tcache_gc_incr_bytes:2147483648",
|
||||
|
|
@ -75,13 +60,13 @@ UNIT_TESTS = [
|
|||
"conf": "abort:false,zero:false,junk:true",
|
||||
},
|
||||
{
|
||||
"name": "unit_junk_alloc",
|
||||
"src": "junk.c",
|
||||
"src": "junk_alloc.c",
|
||||
"deps": [":junk_c"],
|
||||
"conf": "abort:false,zero:false,junk:alloc",
|
||||
},
|
||||
{
|
||||
"name": "unit_junk_free",
|
||||
"src": "junk.c",
|
||||
"src": "junk_free.c",
|
||||
"deps": [":junk_c"],
|
||||
"conf": "abort:false,zero:false,junk:free",
|
||||
},
|
||||
{"src": "log.c"},
|
||||
|
|
@ -125,7 +110,7 @@ UNIT_TESTS = [
|
|||
{
|
||||
"src": "prof_idump.c",
|
||||
"conf": "tcache:false",
|
||||
"prof_conf": ",prof:true,prof_accum:true,prof_active:false,lg_prof_sample:0,lg_prof_interval:0",
|
||||
"prof_conf": "prof:true,prof_accum:true,prof_active:false,lg_prof_sample:0,lg_prof_interval:0",
|
||||
},
|
||||
{
|
||||
"src": "prof_log.c",
|
||||
|
|
@ -233,17 +218,68 @@ transition_default_constraints(
|
|||
visibility = ["//:__subpackages__"],
|
||||
)
|
||||
|
||||
# Handle C source inclusions
|
||||
[
|
||||
cc_library(
|
||||
name = src.replace(".", "_"),
|
||||
testonly = True,
|
||||
hdrs = [src],
|
||||
tags = ["manual"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
for src in [
|
||||
"arena_reset.c",
|
||||
"batch_alloc.c",
|
||||
"junk.c",
|
||||
]
|
||||
]
|
||||
|
||||
[cc_test(
|
||||
name = test["name"] if "name" in test else test["src"].removesuffix(".c").replace("/", "_"),
|
||||
name = test_name(test),
|
||||
srcs = [test["src"]],
|
||||
copts = COPTS,
|
||||
env = select({
|
||||
"//settings/flags:prof": {
|
||||
"JE_TEST_MALLOC_CONF": test.get("conf", "") + test.get("prof_conf", ""),
|
||||
},
|
||||
"//settings/flags:prof": {"JE_TEST_MALLOC_CONF": join_conf(
|
||||
test.get("conf", ""),
|
||||
test.get("prof_conf", ""),
|
||||
)},
|
||||
"//conditions:default": {"JE_TEST_MALLOC_CONF": test.get("conf", "")},
|
||||
}),
|
||||
linkstatic = True,
|
||||
local_defines = ["JEMALLOC_UNIT_TEST"],
|
||||
deps = [":testlib"],
|
||||
deps = [":testlib"] + test.get("deps", []),
|
||||
) for test in UNIT_TESTS]
|
||||
|
||||
cc_test(
|
||||
name = "arena_reset_prof",
|
||||
srcs = ["arena_reset_prof.c"],
|
||||
copts = COPTS,
|
||||
env = {"JE_TEST_MALLOC_CONF": "prof:true,lg_prof_sample:0"},
|
||||
linkstatic = True,
|
||||
local_defines = ["JEMALLOC_UNIT_TEST"],
|
||||
target_compatible_with = select({
|
||||
"//settings/flags:prof": [],
|
||||
"//conditions:default": ["@platforms//:incompatible"],
|
||||
}),
|
||||
deps = [
|
||||
":arena_reset_c",
|
||||
":testlib",
|
||||
],
|
||||
)
|
||||
|
||||
cc_test(
|
||||
name = "batch_alloc_prof",
|
||||
srcs = ["batch_alloc_prof.c"],
|
||||
copts = COPTS,
|
||||
env = {"JE_TEST_MALLOC_CONF": "prof:true,lg_prof_sample:14"},
|
||||
linkstatic = True,
|
||||
local_defines = ["JEMALLOC_UNIT_TEST"],
|
||||
target_compatible_with = select({
|
||||
"//settings/flags:prof": [],
|
||||
"//conditions:default": ["@platforms//:incompatible"],
|
||||
}),
|
||||
deps = [
|
||||
":batch_alloc_c",
|
||||
":testlib",
|
||||
],
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue