Skip to content

Commit 41ecd46

Browse files
committed
Add basic test example
1 parent 3fc9406 commit 41ecd46

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
@@ -113,8 +113,9 @@ cc_library(
113113

114114
cc_static_library(
115115
name = "tcmalloc_standalone",
116-
deps = [":tcmalloc"],
117116
tags = ["manual"],
117+
visibility = [":__subpackages__"],
118+
deps = [":tcmalloc"],
118119
)
119120

120121
cc_library(

tcmalloc/testing/BUILD

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,3 +1028,24 @@ create_tcmalloc_testsuite(
10281028
"@com_google_googletest//:gtest_main",
10291029
],
10301030
)
1031+
1032+
cc_import(
1033+
name = "standalone_import",
1034+
static_library = "//tcmalloc:tcmalloc_standalone",
1035+
tags = ["manual"], # TODO: Remove once cc_static_library is always enabled
1036+
alwayslink = True,
1037+
)
1038+
1039+
cc_test(
1040+
name = "standalone_test",
1041+
srcs = ["standalone_test.cc"],
1042+
tags = [
1043+
"manual", # TODO: Remove once cc_static_library is always enabled
1044+
"noasan",
1045+
"nomsan",
1046+
"notsan",
1047+
],
1048+
deps = [
1049+
":standalone_import",
1050+
],
1051+
)
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)