Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: port test/test-api.c #3

Open
wants to merge 1 commit into
base: staging
Choose a base branch
from

Conversation

hchandad
Copy link

Related issue : #2

Tested with app-helloworld and 05-app-googletest on plat: kvm-x86_64

Signed-off-by: Hamza Chandad hchandad@proton.me

patches/port_test_api.patch Outdated Show resolved Hide resolved
@StefanJum
Copy link
Member

@hchandad Hi, I tried testing this pr and got a seg fault on this line, the parameter a is NULL.
The uk_mimalloc_init_internal function is called by uk_mimalloc_region_malloc, and the argument is passed as NULL by mi_unikraft_heap_grow here.

Did you run into this problem before or have any idea why this might be?

I will leave the extended backtrace below if it helps.

#0  uk_mimalloc_init_internal (a=0x0) at /home/stefan/.unikraft/libs/lib-mimalloc/glue.c:174
#1  uk_mimalloc_region_malloc (size=268435456, a=0x0) at /home/stefan/.unikraft/libs/lib-mimalloc/glue.c:108
#2  uk_mimalloc_region_malloc (a=a@entry=0x0, size=size@entry=268435456) at /home/stefan/.unikraft/libs/lib-mimalloc/glue.c:101
#3  0x000000000042f369 in mi_unikraft_heap_grow (try_alignment=<optimised out>, size=268435456) at /home/stefan/.unikraft/apps/helloworld/build/libmimalloc/origin/mimalloc-1.6.1/src/os.c:280
#4  mi_os_mem_alloc (try_alignment=4194304, allow_large=<optimised out>, stats=0x4bc130 <tld_main+176>, is_large=0x7ffff7f1fcc8, commit=false, size=268435456) at /home/stefan/.unikraft/apps/helloworld/build/libmimalloc/origin/mimalloc-1.6.1/src/os.c:462
#5  mi_os_mem_alloc_aligned (allow_large=false, stats=0x4bc130 <tld_main+176>, is_large=0x7ffff7f1fcc8, commit=false, alignment=4194304, size=268435456) at /home/stefan/.unikraft/apps/helloworld/build/libmimalloc/origin/mimalloc-1.6.1/src/os.c:486
#6  _mi_os_alloc_aligned (size=<optimised out>, size@entry=268435456, alignment=alignment@entry=4194304, commit=<optimised out>, large=large@entry=0x7ffff7f1fcc8, tld=tld@entry=0x4bc120 <tld_main+160>) at /home/stefan/.unikraft/apps/helloworld/build/libmimalloc/origin/mimalloc-1.6.1/src/os.c:576
#7  0x000000000043023e in _mi_arena_alloc_aligned (size=size@entry=268435456, alignment=alignment@entry=4194304, commit=commit@entry=0x7ffff7f1fcc0, large=large@entry=0x7ffff7f1fcc8, is_zero=is_zero@entry=0x7ffff7f1fcd0, memid=memid@entry=0x7ffff7f1fcd8, tld=0x4bc120 <tld_main+160>) at /home/stefan/.unikraft/apps/helloworld/build/libmimalloc/origin/mimalloc-1.6.1/src/arena.c:204
#8  0x0000000000430982 in mi_region_try_alloc_os (tld=0x4bc120 <tld_main+160>, bit_idx=<synthetic pointer>, region=<synthetic pointer>, allow_large=<optimised out>, commit=false, blocks=1) at /home/stefan/.unikraft/apps/helloworld/build/libmimalloc/origin/mimalloc-1.6.1/src/region.c:181
#9  mi_region_try_alloc (tld=0x4bc120 <tld_main+160>, memid=0x7ffff7f1fd68, is_zero=0x7ffff7f1fd65, is_large=0x7ffff7f1fd66, commit=0x7ffff7f1fd64, blocks=1) at /home/stefan/.unikraft/apps/helloworld/build/libmimalloc/origin/mimalloc-1.6.1/src/region.c:270
#10 _mi_mem_alloc_aligned (size=size@entry=4194304, alignment=alignment@entry=4194304, commit=commit@entry=0x7ffff7f1fd64, large=large@entry=0x7ffff7f1fd66, is_zero=is_zero@entry=0x7ffff7f1fd65, memid=memid@entry=0x7ffff7f1fd68, tld=0x4bc120 <tld_main+160>) at /home/stefan/.unikraft/apps/helloworld/build/libmimalloc/origin/mimalloc-1.6.1/src/region.c:356
#11 0x0000000000431fad in mi_segment_init (segment=0x0, required=<optimised out>, page_kind=MI_PAGE_SMALL, page_shift=16, tld=0x4bc0a0 <tld_main+32>, os_tld=0x4bc120 <tld_main+160>) at /home/stefan/.unikraft/apps/helloworld/build/libmimalloc/origin/mimalloc-1.6.1/src/segment.c:625
#12 0x00000000004323cf in mi_segment_alloc (os_tld=0x4bc120 <tld_main+160>, tld=0x4bc0a0 <tld_main+32>, page_shift=16, page_kind=MI_PAGE_SMALL, required=0) at /home/stefan/.unikraft/apps/helloworld/build/libmimalloc/origin/mimalloc-1.6.1/src/segment.c:682
#13 mi_segment_reclaim_or_alloc (os_tld=0x4bc120 <tld_main+160>, tld=0x4bc0a0 <tld_main+32>, page_shift=16, page_kind=MI_PAGE_SMALL, block_size=8, heap=0x4bb4a0 <_mi_heap_main>) at /home/stefan/.unikraft/apps/helloworld/build/libmimalloc/origin/mimalloc-1.6.1/src/segment.c:1201
#14 mi_segment_reclaim_or_alloc (heap=0x4bb4a0 <_mi_heap_main>, block_size=8, page_kind=MI_PAGE_SMALL, page_shift=16, tld=0x4bc0a0 <tld_main+32>, os_tld=0x4bc120 <tld_main+160>) at /home/stefan/.unikraft/apps/helloworld/build/libmimalloc/origin/mimalloc-1.6.1/src/segment.c:1178
#15 0x0000000000432ad7 in mi_segment_page_alloc (os_tld=<optimised out>, tld=0x4bc0a0 <tld_main+32>, page_shift=16, kind=MI_PAGE_SMALL, block_size=8, heap=0x4bb4a0 <_mi_heap_main>) at /home/stefan/.unikraft/apps/helloworld/build/libmimalloc/origin/mimalloc-1.6.1/src/segment.c:1234
#16 mi_segment_small_page_alloc (os_tld=<optimised out>, tld=0x4bc0a0 <tld_main+32>, block_size=8, heap=0x4bb4a0 <_mi_heap_main>) at /home/stefan/.unikraft/apps/helloworld/build/libmimalloc/origin/mimalloc-1.6.1/src/segment.c:1251
#17 _mi_segment_page_alloc (heap=heap@entry=0x4bb4a0 <_mi_heap_main>, block_size=block_size@entry=8, tld=0x4bc0a0 <tld_main+32>, os_tld=<optimised out>) at /home/stefan/.unikraft/apps/helloworld/build/libmimalloc/origin/mimalloc-1.6.1/src/segment.c:1321
#18 0x0000000000432d00 in mi_page_fresh_alloc (heap=heap@entry=0x4bb4a0 <_mi_heap_main>, pq=pq@entry=0x4bb8c8 <_mi_heap_main+1064>, block_size=8) at /home/stefan/.unikraft/apps/helloworld/build/libmimalloc/origin/mimalloc-1.6.1/src/page.c:247
#19 0x000000000043401f in mi_page_fresh (pq=0x4bb8c8 <_mi_heap_main+1064>, heap=0x4bb4a0 <_mi_heap_main>) at /home/stefan/.unikraft/apps/helloworld/build/libmimalloc/origin/mimalloc-1.6.1/src/page.c:264
#20 mi_page_queue_find_free_ex (heap=heap@entry=0x4bb4a0 <_mi_heap_main>, pq=pq@entry=0x4bb8c8 <_mi_heap_main+1064>, first_try=first_try@entry=true) at /home/stefan/.unikraft/apps/helloworld/build/libmimalloc/origin/mimalloc-1.6.1/src/page.c:679
#21 0x00000000004341d9 in mi_find_free_page (size=0, heap=0x4bb4a0 <_mi_heap_main>) at /home/stefan/.unikraft/apps/helloworld/build/libmimalloc/origin/mimalloc-1.6.1/src/page.c:713
#22 _mi_malloc_generic (heap=0x4bb4a0 <_mi_heap_main>, size=0) at /home/stefan/.unikraft/apps/helloworld/build/libmimalloc/origin/mimalloc-1.6.1/src/page.c:810
#23 0x00000000004349a0 in mi_heap_malloc (size=0, heap=<optimised out>) at /home/stefan/.unikraft/apps/helloworld/build/libmimalloc/origin/mimalloc-1.6.1/src/alloc.c:89
#24 _mi_heap_malloc_zero (heap=<optimised out>, size=0, zero=zero@entry=true) at /home/stefan/.unikraft/apps/helloworld/build/libmimalloc/origin/mimalloc-1.6.1/src/alloc.c:134
#25 0x0000000000434c90 in mi_heap_zalloc (size=<optimised out>, heap=<optimised out>) at /home/stefan/.unikraft/apps/helloworld/build/libmimalloc/origin/mimalloc-1.6.1/src/alloc.c:142
#26 0x0000000000438cfd in _uk_testsuite_libmimalloc_api_testsuite_case_calloc0 (esac=0x4b9c2c <_uk_testtab_libmimalloc_api_testsuite_calloc0>) at /home/stefan/.unikraft/apps/helloworld/build/libmimalloc/origin/mimalloc-1.6.1/test/test-api-uk-port.c:65
#27 0x0000000000414f92 in uk_testsuite_run (suite=0x4b9c10 <testsuite_libmimalloc_api_testsuite>) at /home/stefan/.unikraft/unikraft/lib/uktest/test.c:191
#28 0x000000000040de12 in main_thread_func (arg=0x7fffffffdc70) at /home/stefan/.unikraft/unikraft/lib/ukboot/boot.c:100
#29 0x0000000000400585 in asm_thread_starter () at /home/stefan/.unikraft/unikraft/plat/common/x86/thread_start.S:39
#30 0x0000000000000000 in ?? ()

@hchandad
Copy link
Author

@StefanJum the above segv occurs when not choosing mimalloc as the default allocator in the boot section. From

ukbook --> Initialize memory allocator --> Mimalloc

Thank you for the detailed info and apologies for not including testing steps, here is what i did:

Expand

Changes to app-helloworld Makefile

diff --git a/Makefile b/Makefile
index 5426bae..5310f8a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 UK_ROOT ?= $(PWD)/../../unikraft
 UK_LIBS ?= $(PWD)/../../libs
-LIBS :=
+LIBS := $(UK_LIBS)/lib-pthread-embedded:$(UK_LIBS)/lib-newlib:$(UK_LIBS)/lib-mimalloc

 all:
        @$(MAKE) -C $(UK_ROOT) A=$(PWD) L=$(LIBS)

from the menuconfig i set:

  • ukbook --> initialize memory allocator --> Mimalloc
  • mimalloc --> Enable libmimalloc tests
#
# Automatically generated file; DO NOT EDIT.
# Unikraft/0.10.0~9bf6e63 Configuration
#
CONFIG_UK_FULLVERSION="0.10.0~9bf6e63"
CONFIG_UK_CODENAME="Phoebe"
CONFIG_UK_ARCH="x86_64"
CONFIG_UK_BASE="/home/vagrant/unikraft/unikraft"
CONFIG_UK_APP="/home/vagrant/unikraft/apps/app-helloworld"
CONFIG_UK_DEFNAME="app-helloworld"

#
# Architecture Selection
#
CONFIG_ARCH_X86_64=y
# CONFIG_ARCH_ARM_64 is not set
# CONFIG_ARCH_ARM_32 is not set
# CONFIG_MARCH_X86_64_NATIVE is not set
CONFIG_MARCH_X86_64_GENERIC=y
# CONFIG_MARCH_X86_64_NOCONA is not set
# CONFIG_MARCH_X86_64_CORE2 is not set
# CONFIG_MARCH_X86_64_COREI7 is not set
# CONFIG_MARCH_X86_64_COREI7AVX is not set
# CONFIG_MARCH_X86_64_COREI7AVXI is not set
# CONFIG_MARCH_X86_64_ATOM is not set
# CONFIG_MARCH_X86_64_K8 is not set
# CONFIG_MARCH_X86_64_K8SSE3 is not set
# CONFIG_MARCH_X86_64_AMDFAM10 is not set
# CONFIG_MARCH_X86_64_BTVER1 is not set
# CONFIG_MARCH_X86_64_BDVER1 is not set
# CONFIG_MARCH_X86_64_BDVER2 is not set
# CONFIG_MARCH_X86_64_BDVER3 is not set
# CONFIG_MARCH_X86_64_BTVER2 is not set
CONFIG_STACK_SIZE_PAGE_ORDER=4
# end of Architecture Selection

#
# Platform Configuration
#
CONFIG_PLAT_KVM=y

#
# Console Options
#
CONFIG_KVM_KERNEL_SERIAL_CONSOLE=y
CONFIG_KVM_KERNEL_VGA_CONSOLE=y
CONFIG_KVM_DEBUG_SERIAL_CONSOLE=y
CONFIG_KVM_DEBUG_VGA_CONSOLE=y

#
# Serial console configuration
#
CONFIG_KVM_SERIAL_BAUD_115200=y
# CONFIG_KVM_SERIAL_BAUD_57600 is not set
# CONFIG_KVM_SERIAL_BAUD_38400 is not set
# CONFIG_KVM_SERIAL_BAUD_19200 is not set
# end of Serial console configuration
# end of Console Options

CONFIG_KVM_MAX_IRQ_HANDLER_ENTRIES=8
CONFIG_KVM_PCI=y
CONFIG_VIRTIO_BUS=y

#
# Virtio
#
# CONFIG_VIRTIO_PCI is not set
# end of Virtio

CONFIG_UKPLAT_ALLOW_GIC=y
# CONFIG_PLAT_LINUXU is not set
# CONFIG_PLAT_XEN is not set

#
# Platform Interface Options
#
# CONFIG_UKPLAT_MEMRNAME is not set
CONFIG_UKPLAT_LCPU_MAXCOUNT=1
# CONFIG_PAGING is not set
# end of Platform Interface Options

CONFIG_HZ=100
# end of Platform Configuration

#
# Library Configuration
#
# CONFIG_LIBDEVFS is not set
# CONFIG_LIBFDT is not set
# CONFIG_LIBISRLIB is not set
# CONFIG_LIBPOSIX_EVENT is not set
# CONFIG_LIBPOSIX_FUTEX is not set
# CONFIG_LIBPOSIX_LIBDL is not set
CONFIG_LIBPOSIX_PROCESS=y
# CONFIG_LIBPOSIX_SOCKET is not set
CONFIG_LIBPOSIX_SYSINFO=y
CONFIG_LIBPOSIX_USER=y
# CONFIG_LIBRAMFS is not set
# CONFIG_LIBSYSCALL_SHIM is not set
# CONFIG_LIBUBSAN is not set
# CONFIG_LIBUK9P is not set
CONFIG_LIBUKALLOC=y
# CONFIG_LIBUKALLOC_IFMALLOC is not set
# CONFIG_LIBUKALLOC_IFSTATS is not set
CONFIG_LIBUKALLOCBBUDDY=y
# CONFIG_LIBUKALLOCPOOL is not set
CONFIG_LIBUKALLOCREGION=y
CONFIG_LIBUKARGPARSE=y
# CONFIG_LIBUKARGPARSE_TEST is not set
# CONFIG_LIBUKBLKDEV is not set
CONFIG_LIBUKBOOT=y
# CONFIG_LIBUKBOOT_BANNER_NONE is not set
# CONFIG_LIBUKBOOT_BANNER_MINIMAL is not set
# CONFIG_LIBUKBOOT_BANNER_CLASSIC is not set
CONFIG_LIBUKBOOT_BANNER_POWEREDBY=y
# CONFIG_LIBUKBOOT_BANNER_POWEREDBY_ANSI is not set
# CONFIG_LIBUKBOOT_BANNER_POWEREDBY_ANSI2 is not set
# CONFIG_LIBUKBOOT_BANNER_POWEREDBY_EA is not set
# CONFIG_LIBUKBOOT_BANNER_POWEREDBY_EAANSI is not set
# CONFIG_LIBUKBOOT_BANNER_POWEREDBY_EAANSI2 is not set
# CONFIG_LIBUKBOOT_BANNER_POWEREDBY_U8 is not set
# CONFIG_LIBUKBOOT_BANNER_POWEREDBY_U8ANSI is not set
# CONFIG_LIBUKBOOT_BANNER_POWEREDBY_U8ANSI2 is not set
CONFIG_LIBUKBOOT_MAXNBARGS=60
# CONFIG_LIBUKBOOT_INITBBUDDY is not set
# CONFIG_LIBUKBOOT_INITREGION is not set
CONFIG_LIBUKBOOT_INITMIMALLOC=y
# CONFIG_LIBUKBOOT_NOALLOC is not set
CONFIG_LIBUKBUS=y
# CONFIG_LIBUKCPIO is not set
CONFIG_LIBUKDEBUG=y
CONFIG_LIBUKDEBUG_PRINTK=y
# CONFIG_LIBUKDEBUG_PRINTK_INFO is not set
# CONFIG_LIBUKDEBUG_PRINTK_WARN is not set
CONFIG_LIBUKDEBUG_PRINTK_ERR=y
# CONFIG_LIBUKDEBUG_PRINTK_CRIT is not set
# CONFIG_LIBUKDEBUG_PRINTD is not set
# CONFIG_LIBUKDEBUG_NOREDIR is not set
CONFIG_LIBUKDEBUG_REDIR_PRINTD=y
# CONFIG_LIBUKDEBUG_REDIR_PRINTK is not set
CONFIG_LIBUKDEBUG_PRINT_TIME=y
# CONFIG_LIBUKDEBUG_PRINT_CALLER is not set
CONFIG_LIBUKDEBUG_PRINT_SRCNAME=y
# CONFIG_LIBUKDEBUG_ANSI_COLOR is not set
CONFIG_LIBUKDEBUG_ENABLE_ASSERT=y
# CONFIG_LIBUKDEBUG_TRACEPOINTS is not set
# CONFIG_LIBUKFALLOC is not set
# CONFIG_LIBUKFALLOCBUDDY is not set
# CONFIG_LIBUKLIBPARAM is not set
CONFIG_LIBUKLOCK=y
CONFIG_LIBUKLOCK_SEMAPHORE=y
CONFIG_LIBUKLOCK_MUTEX=y
# CONFIG_LIBUKLOCK_MUTEX_METRICS is not set
# CONFIG_LIBUKMMAP is not set
# CONFIG_LIBUKMPI is not set
# CONFIG_LIBUKNETDEV is not set
# CONFIG_LIBUKRING is not set
# CONFIG_LIBUKRUST is not set
CONFIG_LIBUKSCHED=y
CONFIG_LIBUKSCHEDCOOP=y
CONFIG_LIBUKSGLIST=y
CONFIG_LIBUKSIGNAL=y
# CONFIG_LIBUKSP is not set
# CONFIG_LIBUKSTORE is not set
# CONFIG_LIBUKSWRAND is not set
CONFIG_LIBUKTEST=y
CONFIG_LIBUKTEST_ALL=y
# CONFIG_LIBUKTEST_FAILFAST is not set
CONFIG_LIBUKTEST_LOG_TESTS=y
CONFIG_LIBUKTEST_LOG_STATS=y
CONFIG_LIBUKTEST_TEST_MYSELF=y
CONFIG_LIBUKTIME=y
CONFIG_LIBUKTIMECONV=y
CONFIG_LIBVFSCORE=y

#
# vfscore: Configuration
#
CONFIG_LIBVFSCORE_PIPE_SIZE_ORDER=16
# CONFIG_LIBVFSCORE_AUTOMOUNT_ROOTFS is not set
# end of vfscore: Configuration

CONFIG_HAVE_BOOTENTRY=y
CONFIG_HAVE_LIBC=y
CONFIG_HAVE_TIME=y
CONFIG_HAVE_SCHED=y
CONFIG_LIBPTHREAD_EMBEDDED=y
CONFIG_LIBPTHREAD_EMBEDDED_MAX_SIMUL_THREADS=32
CONFIG_LIBPTHREAD_EMBEDDED_MAX_TLS=32
# CONFIG_LIBPTHREAD_EMBEDDED_UTEST is not set
CONFIG_LIBNEWLIBM=y
CONFIG_LIBNEWLIBC=y
# CONFIG_LIBNEWLIBC_WANT_IO_C99_FORMATS is not set
# CONFIG_LIBNEWLIBC_LINUX_ERRNO_EXTENSIONS is not set
CONFIG_LIBNEWLIBC_CRYPT=y
CONFIG_LIBMIMALLOC_INCLUDED=y
CONFIG_LIBMIMALLOC=y
CONFIG_MIMALLOC_DEBUG=0
# CONFIG_MIMALLOC_ASSERT is not set
CONFIG_LIBMIMALLOC_TEST=y
CONFIG_LIBMIMALLOC_TEST_API=y
# end of Library Configuration

#
# Build Options
#
# CONFIG_OPTIMIZE_NONE is not set
CONFIG_OPTIMIZE_PERF=y
# CONFIG_OPTIMIZE_SIZE is not set

#
# Hint: Specify a CPU type to get most benefits from performance optimization
#
CONFIG_OPTIMIZE_NOOMITFP=y
# CONFIG_OPTIMIZE_DEADELIM is not set
# CONFIG_OPTIMIZE_LTO is not set
# CONFIG_DEBUG_SYMBOLS_LVL0 is not set
# CONFIG_DEBUG_SYMBOLS_LVL1 is not set
# CONFIG_DEBUG_SYMBOLS_LVL2 is not set
CONFIG_DEBUG_SYMBOLS_LVL3=y
# CONFIG_OPTIMIZE_WARNISERROR is not set
# CONFIG_OPTIMIZE_SYMFILE is not set
CONFIG_OPTIMIZE_COMPRESS=y
# CONFIG_RECORD_BUILDTIME is not set
CONFIG_CROSS_COMPILE=""
CONFIG_LLVM_TARGET_ARCH=""
# end of Build Options

#
# Application Options
#
CONFIG_APPHELLOWORLD_DEPENDENCIES=y
CONFIG_APPHELLOWORLD_PRINTARGS=y
# CONFIG_APPHELLOWORLD_SPINNER is not set
# end of Application Options

CONFIG_UK_NAME="app-helloworld"

I only ported test-api.c, test-stress.c does fail for me when running as app-helloworld entrypoint -without porting it- ( i still haven't figured out how to do backtraces)

@StefanJum
Copy link
Member

@hchandad thank you, it works now.
From what I see, you did not modify the original test sources, but added a new source file that ports the tests, is that right?
If so, it's fine, but I would add it as a source file in lib-mimalloc/tests/, not as a patch. You can see an example here.

@hchandad
Copy link
Author

hchandad commented Sep 19, 2022

@StefanJum actually it is a change to the original sources, but i added it as a separate file, to make it possible to cd build/libmimalloc/origin and build the original testsuite, i though it might be useful for easy comparisons in case things break.
I can submit it as a patch to test-api.c Updated !

Copy link
Member

@StefanJum StefanJum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job @hchandad thank you!
I left an initial round of review.
Besides the comments, can you please also run checkpatch on your patch? It looks like there are a few spacing issues.
Also please squash your commits, we ideally want only one commit with a relevant message (see here).

patches/port_test_api.patch Outdated Show resolved Hide resolved
Config.uk Show resolved Hide resolved
Makefile.uk Outdated Show resolved Hide resolved
Makefile.uk Outdated Show resolved Hide resolved
patches/port_test_api.patch Outdated Show resolved Hide resolved
@hchandad
Copy link
Author

@StefanJum I made changes to the coding style, using checkpatch.pl.
currently the errors left i believe are related to c++, yet the spacing issue in the patch persists, i believe they are in the original source file.

checkpatch.pl output:
ERROR: spaces required around that '<' (ctx:VxV)
#444: FILE: test/test-api.c:259:
+       std::vector<int, mi_stl_allocator<int>> vec;
                   ^

ERROR: spaces required around that '<' (ctx:VxV)
#444: FILE: test/test-api.c:259:
+       std::vector<int, mi_stl_allocator<int>> vec;
                                         ^

ERROR: need consistent spacing around '>>' (ctx:VxW)
#444: FILE: test/test-api.c:259:
+       std::vector<int, mi_stl_allocator<int>> vec;
                                             ^

WARNING: labels should not be indented
#444: FILE: test/test-api.c:259:
+       std::vector<int, mi_stl_allocator<int>> vec;

ERROR: spaces required around that '<' (ctx:VxV)
#456: FILE: test/test-api.c:271:
+       std::vector<some_struct, mi_stl_allocator<some_struct>> vec;
                   ^

ERROR: spaces required around that '<' (ctx:VxV)
#456: FILE: test/test-api.c:271:
+       std::vector<some_struct, mi_stl_allocator<some_struct>> vec;
                                                 ^

ERROR: need consistent spacing around '>>' (ctx:VxW)
#456: FILE: test/test-api.c:271:
+       std::vector<some_struct, mi_stl_allocator<some_struct>> vec;
                                                             ^

WARNING: labels should not be indented
#456: FILE: test/test-api.c:271:
+       std::vector<some_struct, mi_stl_allocator<some_struct>> vec;

total: 6 errors, 2 warnings, 449 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

./0001-test-use-uk-test.h-in-test-api.c.patch has style problems, please review.

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.

@StefanJum
Copy link
Member

@hchandad you can ignore the errors coming from the original file, just make sure your changes do not produce any more errors.

Copy link
Member

@StefanJum StefanJum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hchandad just few minor changes

Config.uk Outdated Show resolved Hide resolved
patches/0001-test-use-uk-test.h-in-test-api.c.patch Outdated Show resolved Hide resolved
patches/0001-test-use-uk-test.h-in-test-api.c.patch Outdated Show resolved Hide resolved
Copy link
Member

@StefanJum StefanJum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just realised I forgot to add a comment to the previous review, sorry :)

Makefile.uk Outdated Show resolved Hide resolved
@hchandad
Copy link
Author

@StefanJum Thank you, I have updated with the following changes:

diff --git a/Config.uk b/Config.uk
index eb3e7a1..05e2c73 100644
--- a/Config.uk
+++ b/Config.uk
@@ -22,13 +22,12 @@ if LIBMIMALLOC
                Config LIBMIMALLOC_TES
                bool "Enable libmimalloc tests"
                select LIBUKTEST
-               select LIBMIMALLOC_TEST_API
                default n
                help
                        Enables all libmimalloc tests.
        if LIBMIMALLOC_TEST
                config LIBMIMALLOC_TEST_API
                        bool "Enable libmimalloc api test suite"
-                       default n
+                       default y
        endif                                                                                                                                                                                                     endif
diff --git a/Makefile.uk b/Makefile.uk
index f9df74f..0e9fc37 100644
--- a/Makefile.uk
+++ b/Makefile.uk
@@ -97,6 +97,6 @@ LIBMIMALLOC_SRCS-y += $(LIBMIMALLOC)/src/init.c
 ################################################################################
 # Tests
 ################################################################################
-ifneq ($(filter y, $(CONFIG_LIBMIMALLOC_TEST) $(CONFIG_LIBUKTEST_ALL)),)
+ifneq ($(filter y, $(CONFIG_LIBMIMALLOC_TEST_API) $(CONFIG_LIBUKTEST_ALL)),)
 LIBMIMALLOC_SRCS-y += $(LIBMIMALLOC)/test/test-api.c
 endif

Copy link
Member

@StefanJum StefanJum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @hchandad, one last round of review, then I will approve this.
Also, the commit was messed up somewhere, is shows
hchandad authored and Ubuntu committed.
Please also fix that.

patches/0001-test-use-uk-test.h-in-test-api.c.patch Outdated Show resolved Hide resolved
Signed-off-by: Hamza Chandad <hchandad@proton.me>
@hchandad
Copy link
Author

@StefanJum fixed.

Copy link
Member

@StefanJum StefanJum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good on my side, great work @hchandad.
@razvand can you please also take a look at this?

@razvand razvand self-assigned this Oct 5, 2022
@razvand razvand linked an issue Oct 5, 2022 that may be closed by this pull request
@razvand razvand added enhancement New feature or request kind/hackathon Hackathon challenge labels Oct 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request kind/hackathon Hackathon challenge
Projects
Status: 🧊 Icebox
Development

Successfully merging this pull request may close these issues.

Add library tests as unit tests
3 participants