Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp766891pxp; Fri, 11 Mar 2022 14:34:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJySo4ryrdf+fqPcliFCqo65sRMjO28tdlWy/WwHhf0jftiBZd1SpAI2jC/adAizMharx6aG X-Received: by 2002:a17:903:1011:b0:151:bd0e:bc5c with SMTP id a17-20020a170903101100b00151bd0ebc5cmr12626408plb.79.1647038083959; Fri, 11 Mar 2022 14:34:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1647038083; cv=none; d=google.com; s=arc-20160816; b=tt9I/LQ+HJJoci2q2I4Y85cfLyioPy1ydX/+Xns/aVVDNDRBg8ybxgKuhDNbCl0YeZ eeIyTw/KQNlrm/pSr0M6t8AGH0w7i79f269Elrjo/Xj44kvJtucky78pgzDhu3rgZQpp x//i2Uj8HeK9bo9I/zEHJxtRG38LNM33MZLLYaS6XjO+SReIZy6R6G9OmZEGSRrRdQGJ vGPjLaj0Y9PR18N+TMZuRPxUY1BZ2UfUuTbfzPK4x56goKwcdq9Zus06u8VIlLkM3/fz gxjlblAO+F4s0CuRgzkEFHf2qpcqcDl8xgsliwr2+puCAbYFbY5rctubdphpkYuVEMmY kfow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PfFSPTWiAxOHXxpoOxuYzI006DPifNqh9ag3eFnVu00=; b=ZjR//BCCwv1u5f12gXti4IKqxkFIxBZ42oS/jKOSU0TQHzYWjuywkWykREChvfXM/X BZ5UMhH6ogdQmjatQlHBaVGslsaqMl7OsMXn3AqAXu1Io8aiKtFNgOhu0anlT+h696wr 9rBYDcevBoM6A7GL2mikoscGjcYEQZRHA5N0qOyixdjFeH0QHP+Gu+h9KpP/k0XZbHS4 yBZLo2w7Zn1MdLmHd9koZJtdOCBiQ+Ol0EHWPPARc1AgkdMnAMxKrXY5bk+IE5Q38Q4U UJeCUFPvWOJkR9q651QnZo0HDfEBHg1LYNDkLU4nhPUEBs5jIESwFYvhHsZ8Oc7IkfV0 MB5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=CHxJLstL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id u124-20020a626082000000b004f6e4dc7557si8664570pfb.191.2022.03.11.14.34.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Mar 2022 14:34:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@axis.com header.s=axis-central1 header.b=CHxJLstL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DB3871B2AC0; Fri, 11 Mar 2022 13:46:11 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350360AbiCKQ1p (ORCPT + 99 others); Fri, 11 Mar 2022 11:27:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350387AbiCKQ0r (ORCPT ); Fri, 11 Mar 2022 11:26:47 -0500 Received: from smtp2.axis.com (smtp2.axis.com [195.60.68.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F2D41D21E2; Fri, 11 Mar 2022 08:25:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1647015914; x=1678551914; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PfFSPTWiAxOHXxpoOxuYzI006DPifNqh9ag3eFnVu00=; b=CHxJLstLXJGaORnyxhiS9rQomGdmNsjUuQkEHZs2haPvt+X1pKcyCAAv Ptpld09X9mK14P/L/y14OqPx+B/mowuKjYg7FSJCBB79TG1lK8TTaCeZZ bTl54vy4R7KZnsldROaHpUgAtFvsc1x9hu/fEU1sDkqdTEn+ifGb45rCw Ve7wNH4VXPajAZDL5OPydSVYrPdB+KwA3jsxW4iqYyHzhxndcNaBi+7CL S967NLsmsgeG4wlp41MWBHpNMn3OLjDvsgkIA2/d6uXpYy4Lre+h3pe9U c0zyxc/6h7EH0ZLn4RuXrTDUopn2L4rfEJKtPqHH7fVbTxdKqi6r8/pNi w==; From: Vincent Whitchurch To: CC: , Vincent Whitchurch , , , , , , , , , , , , , , Subject: [RFC v1 05/10] roadtest: add build files Date: Fri, 11 Mar 2022 17:24:40 +0100 Message-ID: <20220311162445.346685-6-vincent.whitchurch@axis.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220311162445.346685-1-vincent.whitchurch@axis.com> References: <20220311162445.346685-1-vincent.whitchurch@axis.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a Makefile and other miscellaneous build-related files for the roadtest framework. To make it easier to run the tests on systems which do not have the required libraries or Python version, a Dockerfile is included and the Makefile has built-in support for running the tests in a Docker container. Targets for code formatting and static checking of the Python code are included. Signed-off-by: Vincent Whitchurch --- tools/testing/roadtest/.gitignore | 2 + tools/testing/roadtest/Dockerfile | 25 ++++++++ tools/testing/roadtest/Makefile | 84 +++++++++++++++++++++++++ tools/testing/roadtest/pyproject.toml | 10 +++ tools/testing/roadtest/requirements.txt | 4 ++ tools/testing/roadtest/src/.gitignore | 1 + 6 files changed, 126 insertions(+) create mode 100644 tools/testing/roadtest/.gitignore create mode 100644 tools/testing/roadtest/Dockerfile create mode 100644 tools/testing/roadtest/Makefile create mode 100644 tools/testing/roadtest/pyproject.toml create mode 100644 tools/testing/roadtest/requirements.txt create mode 100644 tools/testing/roadtest/src/.gitignore diff --git a/tools/testing/roadtest/.gitignore b/tools/testing/roadtest/.gitignore new file mode 100644 index 000000000000..0cbd00343694 --- /dev/null +++ b/tools/testing/roadtest/.gitignore @@ -0,0 +1,2 @@ +__pycache__ +.py[cod] diff --git a/tools/testing/roadtest/Dockerfile b/tools/testing/roadtest/Dockerfile new file mode 100644 index 000000000000..f2982179c327 --- /dev/null +++ b/tools/testing/roadtest/Dockerfile @@ -0,0 +1,25 @@ +FROM debian:bullseye + +# Kernel build +RUN apt-get update && apt-get -y install \ + bc \ + build-essential \ + flex \ + bison \ + rsync \ + kmod + +# Running roadtests +RUN apt-get update && apt-get -y install \ + python3.9 \ + libpython3.9-dev \ + python3 \ + device-tree-compiler + +# Development and debugging +RUN apt-get update && apt-get -y install \ + uml-utilities \ + telnetd \ + python3-pip +COPY requirements.txt /tmp/ +RUN pip install --requirement /tmp/requirements.txt diff --git a/tools/testing/roadtest/Makefile b/tools/testing/roadtest/Makefile new file mode 100644 index 000000000000..525b26581142 --- /dev/null +++ b/tools/testing/roadtest/Makefile @@ -0,0 +1,84 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Copyright Axis Communications AB + +.PHONY: all build-kernel test clean check fmt docker-run + +all: + +KSOURCE := ${PWD} +ROADTEST_DIR = ${CURDIR} +ROADTEST_BUILD_DIR := ${KSOURCE}/.roadtest +KHEADERS := ${ROADTEST_BUILD_DIR}/usr +KMODULES := ${ROADTEST_BUILD_DIR}/modules + +ifeq (${KSOURCE},${ROADTEST_DIR}) +# Make make from the standard roadtest directory work without having to set +# additional variables. +KSOURCE=$(ROADTEST_DIR:/tools/testing/roadtest=) +endif + +CFLAGS += -g -D_GNU_SOURCE=1 -Wall -Werror -std=gnu99 \ + -I${KSOURCE}/tools/include/ \ + -I${KHEADERS}/include/ \ + -I${ROADTEST_DIR}/src/libvhost-user/ \ + $(shell python3-config --embed --includes) -O2 + +${ROADTEST_BUILD_DIR}/roadtest-backend: ${ROADTEST_BUILD_DIR}/backend.o ${ROADTEST_BUILD_DIR}/libvhost-user.o + $(CC) -o $@ $^ $(shell python3-config --embed --libs) + # For the benefit of clangd + echo ${CFLAGS} | tr " " "\n" > ${ROADTEST_DIR}/src/compile_flags.txt + +${ROADTEST_BUILD_DIR}/backend.o: src/backend.c + $(CC) -c -o $@ $(CFLAGS) $< + +${ROADTEST_BUILD_DIR}/libvhost-user.o: src/libvhost-user/libvhost-user.c + $(CC) -c -o $@ $(CFLAGS) $< + +clean: + rm -rf ${ROADTEST_BUILD_DIR} .docker_built + +ifeq ($(DOCKER),1) +.docker_built: Dockerfile requirements.txt + docker build --network=host -t roadtest ${ROADTEST_DIR} + touch $@ + +# --network=host allows UML's con=port:... to work seamlessly +docker-run: .docker_built + mkdir -p ${ROADTEST_BUILD_DIR}/umltmp + docker run --network=host ${DOCKEROPTS} --user $(shell id -u ${USER}):$(shell id -g ${USER}) --interactive --tty --rm -v ${KSOURCE}:${KSOURCE} -w ${KSOURCE} --env TMPDIR=${ROADTEST_BUILD_DIR}/umltmp roadtest sh -c '${MAKE} -C ${ROADTEST_DIR} -${MAKEFLAGS} ${MAKECMDGOALS} DOCKER=0' + +all test build-kernel check fmt: docker-run + @: +else +all: test + +ifneq ($(KBUILD),0) +# Calling make on the kernel is slow even if there is nothing to be rebuilt. +# Allow the user to avoid it with KBUILD=0 +${ROADTEST_BUILD_DIR}/backend.o: build-kernel +${ROADTEST_BUILD_DIR}/libvhost-user.o: build-kernel +test: build-kernel +endif + +build-kernel: + mkdir -p ${ROADTEST_BUILD_DIR} + find ${ROADTEST_DIR}/roadtest/tests/ -type f -name config | xargs cat > ${ROADTEST_BUILD_DIR}/.config + ${MAKE} -C ${KSOURCE} ARCH=um O=${ROADTEST_BUILD_DIR} olddefconfig + ${MAKE} -C ${KSOURCE} ARCH=um O=${ROADTEST_BUILD_DIR} + ${MAKE} -C ${KSOURCE} ARCH=um O=${ROADTEST_BUILD_DIR} INSTALL_HDR_PATH=${KHEADERS} headers_install + ${MAKE} -C ${KSOURCE} ARCH=um O=${ROADTEST_BUILD_DIR} INSTALL_MOD_PATH=${KMODULES} modules_install + +test: ${ROADTEST_BUILD_DIR}/roadtest-backend + python3 -m roadtest.cmd.main --ksrc-dir ${KSOURCE} --build-dir ${ROADTEST_BUILD_DIR} --work-dir ${ROADTEST_BUILD_DIR}/roadtest-work/ ${OPTS} + +check: + mypy --no-error-summary roadtest + pyflakes roadtest + black --check roadtest + isort --profile black --check roadtest + +fmt: + black roadtest + isort --profile black roadtest + +endif diff --git a/tools/testing/roadtest/pyproject.toml b/tools/testing/roadtest/pyproject.toml new file mode 100644 index 000000000000..6b8b05eb3cad --- /dev/null +++ b/tools/testing/roadtest/pyproject.toml @@ -0,0 +1,10 @@ +[tool.isort] +profile = "black" + +[tool.mypy] +disallow_untyped_defs = true +check_untyped_defs = true +no_implicit_optional = true +warn_return_any = true +warn_unused_ignores = true +show_error_codes = true diff --git a/tools/testing/roadtest/requirements.txt b/tools/testing/roadtest/requirements.txt new file mode 100644 index 000000000000..e1ac403d826e --- /dev/null +++ b/tools/testing/roadtest/requirements.txt @@ -0,0 +1,4 @@ +black==22.1.0 +isort==5.10.1 +mypy==0.931 +pyflakes==2.4.0 diff --git a/tools/testing/roadtest/src/.gitignore b/tools/testing/roadtest/src/.gitignore new file mode 100644 index 000000000000..895dab3fe4be --- /dev/null +++ b/tools/testing/roadtest/src/.gitignore @@ -0,0 +1 @@ +compile_flags.txt -- 2.34.1