Skip to content

Commit d61809d

Browse files
committed
Add basic test example
1 parent bddb2de commit d61809d

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

tcmalloc/BUILD

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,9 @@ cc_library(
119119

120120
cc_static_library(
121121
name = "tcmalloc_standalone",
122-
deps = [":tcmalloc"],
123122
tags = ["manual"],
123+
visibility = [":__subpackages__"],
124+
deps = [":tcmalloc"],
124125
)
125126

126127
cc_library(

tcmalloc/testing/BUILD

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,3 +1053,24 @@ cc_test(
10531053
"//tcmalloc:alloc_at_least",
10541054
],
10551055
)
1056+
1057+
cc_import(
1058+
name = "standalone_import",
1059+
static_library = "//tcmalloc:tcmalloc_standalone",
1060+
tags = ["manual"], # TODO: Remove once cc_static_library is always enabled
1061+
alwayslink = True,
1062+
)
1063+
1064+
cc_test(
1065+
name = "standalone_test",
1066+
srcs = ["standalone_test.cc"],
1067+
tags = [
1068+
"manual", # TODO: Remove once cc_static_library is always enabled
1069+
"noasan",
1070+
"nomsan",
1071+
"notsan",
1072+
],
1073+
deps = [
1074+
":standalone_import",
1075+
],
1076+
)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include <iostream>
2+
#include <cstddef>
3+
4+
int main() {
5+
std::cout << "Standard Alignment: " << alignof(std::max_align_t) << '\n';
6+
7+
double *ptr = (double*) malloc(sizeof(double));
8+
std::cout << "Double Alignment: " << alignof(*ptr) << '\n';
9+
10+
char *ptr2 = (char*) malloc(1);
11+
std::cout << "Char Alignment: " << alignof(*ptr2) << '\n';
12+
13+
void *ptr3;
14+
std::cout << "Sizeof void*: " << sizeof(ptr3) << '\n';
15+
16+
return 0;
17+
}

0 commit comments

Comments
 (0)