aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/balloc/test
diff options
context:
space:
mode:
authorudovichenko-r <udovichenko-r@yandex-team.ru>2022-07-04 14:16:38 +0300
committerudovichenko-r <udovichenko-r@yandex-team.ru>2022-07-04 14:16:38 +0300
commit5fe1c2b2d90b4ddbd7d1683191a48851363cf53d (patch)
treec413b43fb69611ff1185ead7813a8e0973dca3dc /library/cpp/balloc/test
parentf9651ab5ad67347bf06d6d0789b5d6eb31a7b2cc (diff)
downloadydb-5fe1c2b2d90b4ddbd7d1683191a48851363cf53d.tar.gz
[KIKIMR-15108] Add perf programs to build
ref:8f081efde09627da76e52231d32a83e34b78c1e4
Diffstat (limited to 'library/cpp/balloc/test')
-rw-r--r--library/cpp/balloc/test/do_with_disabled/main.cpp24
-rw-r--r--library/cpp/balloc/test/do_with_enabled/main.cpp24
2 files changed, 48 insertions, 0 deletions
diff --git a/library/cpp/balloc/test/do_with_disabled/main.cpp b/library/cpp/balloc/test/do_with_disabled/main.cpp
new file mode 100644
index 00000000000..245887cb66b
--- /dev/null
+++ b/library/cpp/balloc/test/do_with_disabled/main.cpp
@@ -0,0 +1,24 @@
+#include <library/cpp/balloc/optional/operators.h>
+
+#undef NDEBUG
+
+#include <cstdlib>
+#include <cstring>
+#include <cassert>
+
+// internal hook for the testing
+extern "C" bool IsOwnedByBalloc(void* ptr);
+
+int main() {
+ char* buf = (char*)malloc(100);
+ assert(false == IsOwnedByBalloc(buf));
+
+ ThreadEnableBalloc();
+ char* buf2 = (char*)malloc(100);
+ assert(true == IsOwnedByBalloc(buf2));
+
+ free(buf);
+ free(buf2);
+
+ return 0;
+}
diff --git a/library/cpp/balloc/test/do_with_enabled/main.cpp b/library/cpp/balloc/test/do_with_enabled/main.cpp
new file mode 100644
index 00000000000..02c165ccc3c
--- /dev/null
+++ b/library/cpp/balloc/test/do_with_enabled/main.cpp
@@ -0,0 +1,24 @@
+#include <library/cpp/balloc/optional/operators.h>
+
+#undef NDEBUG
+
+#include <cstdlib>
+#include <cstring>
+#include <cassert>
+
+// internal hook for the testing
+extern "C" bool IsOwnedByBalloc(void* ptr);
+
+int main() {
+ char* buf = (char*)malloc(100);
+ assert(true == IsOwnedByBalloc(buf));
+
+ ThreadDisableBalloc();
+ char* buf2 = (char*)malloc(100);
+ assert(false == IsOwnedByBalloc(buf2));
+
+ free(buf);
+ free(buf2);
+
+ return 0;
+}