File tree 2 files changed +34
-1
lines changed
2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change 19
19
20
20
#include " test_core.h"
21
21
#include " swoole_memory.h"
22
+ #include " swoole_util.h"
22
23
23
24
using namespace std ;
24
25
@@ -47,6 +48,16 @@ TEST(fixed_pool, alloc) {
47
48
pool->free (mem);
48
49
}
49
50
}
50
- pool->debug (2 );
51
+ pool->debug (1 );
51
52
delete pool;
52
53
}
54
+
55
+ TEST (fixed_pool, realloc) {
56
+ void *memory = sw_shm_malloc (1024 );
57
+ void *new_memory = sw_shm_realloc (memory, 2048 );
58
+ ON_SCOPE_EXIT {
59
+ sw_shm_free (new_memory);
60
+ };
61
+ ASSERT_NE (new_memory, nullptr );
62
+
63
+ }
Original file line number Diff line number Diff line change @@ -308,3 +308,25 @@ TEST(table, get_value) {
308
308
row->get_value (column_id, &lval);
309
309
ASSERT_EQ (lval, 0 );
310
310
}
311
+
312
+ TEST (table, lock) {
313
+ table_t table (test_table_size);
314
+ create_table (table);
315
+ auto ptr = table.ptr ();
316
+
317
+ std::string key (" php" );
318
+ TableRow *_rowlock = nullptr ;
319
+
320
+ for (int i = 0 ; i <= 3 ; i++) {
321
+ std::thread t ([&]() {
322
+ TableRow *row = ptr->get (key.c_str (), key.length (), &_rowlock);
323
+ TableColumn *column_name = ptr->get_column (" name" );
324
+ char *str = nullptr ;
325
+ TableStringLength len = 0 ;
326
+ row->get_value (column_name, &str, &len);
327
+ ASSERT_STREQ (str, " php" );
328
+ });
329
+ t.join ();
330
+ }
331
+ _rowlock->unlock ();
332
+ }
You can’t perform that action at this time.
0 commit comments