From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id wBWgEfw072YmAAEAqHPOHw:P1 (envelope-from ) for ; Sat, 21 Sep 2024 23:05:00 +0200 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id wBWgEfw072YmAAEAqHPOHw (envelope-from ) for ; Sat, 21 Sep 2024 23:05:00 +0200 X-Envelope-To: patches@johnnyrichard.com Authentication-Results: aspmx1.migadu.com; none Received: from mail-a.sr.ht (mail-a.sr.ht [46.23.81.152]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 3B9AB6FFD0 for ; Sat, 21 Sep 2024 23:05:00 +0200 (CEST) DKIM-Signature: a=rsa-sha256; bh=zgGl1ZjSLVUnhagmcc11QKLBzmtssq2XdAM/jZnkcq8=; c=simple/simple; d=lists.sr.ht; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Unsubscribe:List-Subscribe:List-Archive:List-Post:List-ID; q=dns/txt; s=20240113; t=1726952700; v=1; b=UQBL9QJFk+TifNHTlIwRuLClz8IJ2hZsCuqil3OqAkPPgOkiwPb60j67rkqDd7mtQDly+7rf 2TMyjItpq9Agjz/qqsYO/LUonulMyrRYXTV07L5NdmeOnpNQtoosQvtgJD4k07J+shZIPnuDiDr JCwwLCzdTOH4wfls+CAfBZSXU7kAJXlG3xT7sukIwubgHtLzDYDf+rZgdQdYxBM9dAEU77c/FyR B9V3cZzWlTlAVgGGcnbB6o6hKdEnD65tszO4/UPRTm4elhFSXraTYfsxdRel8iVQYgFvB424sze MR52/hRN8A/Td9R6aa6l5PrxPPRsiZvphXeYy1Gf8lh8A== Received: from lists.sr.ht (unknown [46.23.81.154]) by mail-a.sr.ht (Postfix) with ESMTPSA id ED8D9202CF for ; Sat, 21 Sep 2024 21:04:59 +0000 (UTC) Received: from out-182.mta1.migadu.com (out-182.mta1.migadu.com [95.215.58.182]) by mail-a.sr.ht (Postfix) with ESMTPS id CD2002026B for <~johnnyrichard/olang-devel@lists.sr.ht>; Sat, 21 Sep 2024 21:04:58 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=johnnyrichard.com; s=key1; t=1726952698; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5YA/nDDqxwB9V0nfbwiAQ1lXyM0rAQOG30TAdPBXkjY=; b=YhoDhhSEUUhxfZ5gR7qn1Mgdq8j/tLR2uOq3A0Tt1HuzcxodgJDU7HGLITZ3KHqatovUzl hRVl0SMRAI0HUFXAnWF0v8654jpyEvQe5fAds9+Q44ViBl6c6ymdVBeNAGam34beZB5Gva a+QN5UxrGGaYYPlc8I43Rkx/XePyuW4iyCrSJtYxxJ6PIDYDncnEg5grEK5PZBVuf8AJf3 834KGhboCm+VyZirvSuJnp/mYjXoS+d+CCGYR6CLEund+F8uCTtIENiD3VSOpLhi2f+e5a unleF+hVRkOJG8ci11O3X5R24RWuXdQ+tUVU9TKhkjiGU8gFPQppKjnWonwQ3Q== From: Johnny Richard To: ~johnnyrichard/olang-devel@lists.sr.ht Cc: Johnny Richard Subject: [PATCH olang v1 2/2] tests: build: add parallelization support for unit tests Date: Sat, 21 Sep 2024 23:02:49 +0200 Message-ID: <20240921210512.1100242-3-johnny@johnnyrichard.com> In-Reply-To: <20240921210512.1100242-1-johnny@johnnyrichard.com> References: <20240921210512.1100242-1-johnny@johnnyrichard.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Sourcehut-Patchset-Status: PROPOSED List-Unsubscribe: List-Subscribe: List-Archive: Archived-At: List-Post: List-ID: ~johnnyrichard/olang-devel <~johnnyrichard/olang-devel.lists.sr.ht> Sender: ~johnnyrichard/olang-devel <~johnnyrichard/olang-devel@lists.sr.ht> X-Migadu-Country: NL X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -4.00 X-Spam-Score: -4.00 X-Migadu-Scanner: mx13.migadu.com X-Migadu-Queue-Id: 3B9AB6FFD0 X-TUID: L4xjqbnU3aNH Removes inline shell script and enable test execution by target on make. Now we should be able to execute tests with more jobs (make -j) Signed-off-by: Johnny Richard --- Makefile | 4 ++-- tests/unit/Makefile | 40 ++++++++++++++++++---------------------- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index 2b65f96..83c88a2 100644 --- a/Makefile +++ b/Makefile @@ -94,8 +94,8 @@ check-execute: $(MAKE) $(MAKE) -C tests/execute/ -.PHONY: unit-test -unit-test: +.PHONY: check-unit +check-unit: $(MAKE) $(MAKE) -C tests/unit/ diff --git a/tests/unit/Makefile b/tests/unit/Makefile index 783225c..686938f 100644 --- a/tests/unit/Makefile +++ b/tests/unit/Makefile @@ -1,33 +1,29 @@ -SRCS := $(wildcard *_test.c) -OBJS := $(patsubst %_test.c, %_test.o, $(SRCS)) -SUBJECT_OBJS := $(filter-out ../../build/main.o, $(wildcard ../../build/*.o)) -CFLAGS := -I../../src -I../shared -TESTS := $(patsubst %_test.c, %_test, $(SRCS)) -EXEC_TESTS := $(patsubst %_test, ./%_test, $(TESTS)) -MUNIT_SRC := ../shared/munit.c -MUNIT := ./munit.o +SRCS := $(wildcard *.c) +DEP_OBJS := $(filter-out ../../build/main.o, $(wildcard ../../build/*.o)) +CFLAGS := -I../../src -I../shared +TESTS := $(patsubst %.c, %.bin, $(SRCS)) +RUN_TESTS := $(patsubst %.bin, %.run, $(TESTS)) +MUNIT_SRC := ../shared/munit.c +MUNIT := ./munit.o -.PHONY: all -all: $(MUNIT) $(TESTS) - @for file in $(EXEC_TESTS); do \ - ./"$$file"; \ - done +.PHONY: all clean format format-fix +all: $(RUN_TESTS) + +%.bin: %.c $(MUNIT) + @$(CC) $(CFLAGS) $(MUNIT) $(DEP_OBJS) $< -o $@ + +%.run: %.bin + @./$< -.PHONY: clean clean: - $(RM) *.o *_test - $(RM) -rfv lib + @$(RM) *.o *.bin + @$(RM) -rfv lib -.PHONY: format format: $(SRCS) clang-format --dry-run --Werror $? -.PHONY: format-fix format-fix: $(SRCS) clang-format -i $? -%_test: $(MUNIT) $(SUBJECT_OBJS) %_test.c - $(CC) $? $(CFLAGS) -o $@ - $(MUNIT): - $(CC) -c $(MUNIT_SRC) $(CFLAGS) -o $(MUNIT) + @$(CC) -c $(MUNIT_SRC) $(CFLAGS) -o $(MUNIT) -- 2.46.0