Skip test for sdsRemoveFreeSpace when mem_allocator is not jemalloc (#11878)

Test `trim on SET with big value` (introduced from #11817) fails under mac m1 with libc mem_allocator.
The reason is that malloc(33000) will allocate 65536 bytes(>42000).
This test still passes under ubuntu with libc mem_allocator.

```
*** [err]: trim on SET with big value in tests/unit/type/string.tcl
Expected [r memory usage key] < 42000 (context: type source line 471 file /Users/iospack/data/redis_fork/tests/unit/type/string.tcl cmd {assert {[r memory usage key] < 42000}} proc ::test)
```

simple test under mac m1 with libc mem_allocator:
```c
void *p = zmalloc(33000);
printf("malloc size: %zu\n", zmalloc_size(p));

# output
malloc size: 65536
```

(cherry picked from commit 3fba3ccd96)
(cherry picked from commit 646069a900)
This commit is contained in:
sundb 2023-03-07 15:06:58 +08:00 committed by Oran Agra
parent 8f30d2a604
commit 89391e42c8
1 changed files with 2 additions and 0 deletions

View File

@ -458,6 +458,7 @@ start_server {tags {"string"}} {
}
}
if {[string match {*jemalloc*} [s mem_allocator]]} {
test {trim on SET with big value} {
# set a big value to trigger increasing the query buf
r set key [string repeat A 100000]
@ -466,6 +467,7 @@ start_server {tags {"string"}} {
# asset the value was trimmed
assert {[r memory usage key] < 42000}; # 42K to count for Jemalloc's additional memory overhead.
}
} ;# if jemalloc
test {Extended SET can detect syntax errors} {
set e {}