From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id ELNwIeA18GapOAAAqHPOHw:P1 (envelope-from ) for ; Sun, 22 Sep 2024 17:21:04 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id ELNwIeA18GapOAAAqHPOHw (envelope-from ) for ; Sun, 22 Sep 2024 17:21:04 +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 753666E169 for ; Sun, 22 Sep 2024 17:21:04 +0200 (CEST) DKIM-Signature: a=rsa-sha256; bh=lavumoZfIgEueboX9mwsEpkewl/cHGEnTCLVuzyQz4M=; 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=1727018463; v=1; b=hHF4wHFmPMppKUkWJUUQe+0BWLXCariBR8Osd/Ra8LqyudhuhK6ofvCdyE0Q5vD2Zk8oxe0/ 0jILR7/uK53ZP5eXbq8Q/prUbyzrxobjb1xyW/rllYEIzNDJ4SF5yzdzR3hucighk5svJSR7BN+ vLoRx9knQhd5Wdy71tqKBhiWqkthUbBXa2F1G5Td8hSAztm+GlqIQ6yeNTcc9Gf8EpcHWFt118Y rSMpVXVmcB6jqE/iYIKPpCtabKNL68KsK9W8vkG7+ZIJAsIMhG+nHs5eMlZvoO0ij5f8d5Wc7B/ LOqMvOAFLcjpi/uFUlx29pU0gibyrNIJNoWqPB9BemrLA== Received: from lists.sr.ht (unknown [46.23.81.154]) by mail-a.sr.ht (Postfix) with ESMTPSA id 905D320284 for ; Sun, 22 Sep 2024 15:21:03 +0000 (UTC) Received: from out-177.mta1.migadu.com (out-177.mta1.migadu.com [95.215.58.177]) by mail-a.sr.ht (Postfix) with ESMTPS id E23872020D for <~johnnyrichard/olang-devel@lists.sr.ht>; Sun, 22 Sep 2024 15:21:02 +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=1727018462; 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=gjv9ayD7koH6IZRTYweBYHMwsG3qMy+EBKIO7xWTXBQ=; b=MXEG4ppeVeMB6G5uSC2qEBuom3Ojj8oerx/wJwwQ6UmwYKL/iRhZwSYkqGD+oMO86vSm12 gp46mzhdMF2VNHRMAZ6/+H1zHdLzXjbKbpOtpYeSt3lFVwxPFuRDEujPi7eQhvJmHDzKtC oSXSEYG/IXhcImlVjkjk4oWO8oldeQDiYKLVk5uEspeMaHq02IEA9AbG/2N/WTP6o9Sn2B 9mmJ+cjSbEcyodFVkWHNCh7MV5qOm/HjkcMJXk2eVgS2L69QDuMTkTy0XnL7U+CB6Nno1A G2cs+Ao5XvFoVe4RBdXtFSqpSXeO1NfhlVyWpN54GLtL7WvShbv8FAkxzSI0bA== From: Johnny Richard To: ~johnnyrichard/olang-devel@lists.sr.ht Cc: Johnny Richard Subject: [PATCH olang v2 3/3] tests: build: add parallelization support for unit tests Date: Sun, 22 Sep 2024 17:15:56 +0200 Message-ID: <20240922152119.1214443-4-johnny@johnnyrichard.com> In-Reply-To: <20240922152119.1214443-1-johnny@johnnyrichard.com> References: <20240922152119.1214443-1-johnny@johnnyrichard.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Sourcehut-Patchset-Status: UNKNOWN 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-Flow: FLOW_IN X-Migadu-Country: NL X-Migadu-Queue-Id: 753666E169 X-Migadu-Scanner: mx11.migadu.com X-Spam-Score: -4.00 X-Migadu-Spam-Score: -4.00 X-TUID: GZlf1TnEpuEb 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 | 9 +++------ tests/unit/Makefile | 40 ++++++++++++++++++---------------------- 2 files changed, 21 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index 7dbde3e..3a799ae 100644 --- a/Makefile +++ b/Makefile @@ -93,9 +93,8 @@ format-fix: $(SRCS) $(HEADERS) check-olc: $(TARGET) $(MAKE) -C tests/olc/ -.PHONY: unit-test -unit-test: - $(MAKE) +.PHONY: check-unit +check-unit: $(TARGET) $(MAKE) -C tests/unit/ .PHONY: clean @@ -105,9 +104,7 @@ clean: @rm -rf build/ $(TARGET) .PHONY: check -check: check-olc - $(MAKE) - $(MAKE) -C tests/unit/ +check: check-unit check-olc .PHONY: docs docs: 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