From nobody Mon Feb 9 00:07:19 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617972777; cv=none; d=zohomail.com; s=zohoarc; b=AlsXSo324TOFU7X8SzP2IkVT6TIiWMABKbTsk5S7yxzTnmJpeY3vbVbiBI3RQpwMJ3w4b9Qxke9eWO6oL6w9F53zKDRQXo5NX06Dukh7prJjcxwDJI6J52cSCllzgF1q4xbfNeyXD2fKJLsBRyFAS9+ek08oBVbCfgyXFMIINUY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617972777; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bgVe/5lyxjsYkMzCebjOLuhGkev8qycVBr1OawyqdXs=; b=J9xratNJlchiAbbbnFVqqqC3c/axMPCqXiCOfw+ZuLbTRa0bHtJdZAH+dM0au7PbLRZ6s3lsgN6qGOtDhKfX0GYEhIblsq3tohR1Ms+JvLqgwNIeumaNeP5X3Hx3dPo/MrSYAH/7ofAuITeMeFNTqnGflHWdzDxezVnYIByww6E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1617972777066824.5935999670585; Fri, 9 Apr 2021 05:52:57 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-520-9VIVs5OZNuye_7BG8sRGuQ-1; Fri, 09 Apr 2021 08:52:53 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DEF601006C94; Fri, 9 Apr 2021 12:52:48 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 14D781042A48; Fri, 9 Apr 2021 12:52:48 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C617A55348; Fri, 9 Apr 2021 12:52:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 139Cqd04009396 for ; Fri, 9 Apr 2021 08:52:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id B61295C1D5; Fri, 9 Apr 2021 12:52:39 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE4145C1A1 for ; Fri, 9 Apr 2021 12:52:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617972775; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=bgVe/5lyxjsYkMzCebjOLuhGkev8qycVBr1OawyqdXs=; b=MA5Ty4quM7mpY6fvcd+0+/8T1tUiEvNlmmA7NriIfWTFQdTy/EHjJeCPTGQHtmCwS5ROdn hkBdE27L+Uo41oddrPpA48shyNwIrYZtn6w4BlSt+86860I6u6DYjk9RS8YbyVzwt3mQ3C 8OZKqB25B4vrvCjLHx62Fx0qMij/N9s= X-MC-Unique: 9VIVs5OZNuye_7BG8sRGuQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v2 25/25] Remove test 'args' file rewrapping infrastructure Date: Fri, 9 Apr 2021 14:50:27 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" All tests which use files with 'ldargs' and 'args' suffix as output now use the internal and better line splitting. Remove the test-wrap-argv.py script, the syntax check which used it and the helper rewrapping the output when regenerating test output. For any further use, we require code to use virCommand anyways and thus it has internal wrapping now. Signed-off-by: Peter Krempa --- build-aux/syntax-check.mk | 7 +- scripts/meson.build | 1 - scripts/test-wrap-argv.py | 168 -------------------------------------- tests/testutils.c | 35 +------- 4 files changed, 5 insertions(+), 206 deletions(-) delete mode 100755 scripts/test-wrap-argv.py diff --git a/build-aux/syntax-check.mk b/build-aux/syntax-check.mk index d6eb26c5ec..552d639119 100644 --- a/build-aux/syntax-check.mk +++ b/build-aux/syntax-check.mk @@ -1679,7 +1679,7 @@ sc_prohibit_path_max_allocation: $(_sc_search_regexp) ifneq ($(_gl-Makefile),) -syntax-check: sc_spacing-check sc_test-wrap-argv \ +syntax-check: sc_spacing-check \ sc_prohibit-duplicate-header sc_mock-noinline sc_group-qemu-caps \ sc_header-ifdef @if ! cppi --version >/dev/null 2>&1; then \ @@ -1712,11 +1712,6 @@ sc_header-ifdef: $(AM_V_GEN)$(VC_LIST) | $(GREP) '\.[h]$$' | $(RUNUTF8) xargs \ $(PYTHON) $(top_srcdir)/scripts/header-ifdef.py -sc_test-wrap-argv: - $(AM_V_GEN)$(VC_LIST) | $(GREP) -v -E 'qemuxml2argvdata|nwfilterxml2firew= alldata|bhyvexml2argvdata' \ - |$(GREP) -E '\.(ldargs|args)' | $(RUNUTF8) xargs \ - $(PYTHON) $(top_srcdir)/scripts/test-wrap-argv.py --check - sc_group-qemu-caps: $(AM_V_GEN)$(RUNUTF8) $(PYTHON) $(top_srcdir)/scripts/group-qemu-caps.py \ --check --prefix $(top_srcdir)/ diff --git a/scripts/meson.build b/scripts/meson.build index 655ec0e0e2..421e3d2acd 100644 --- a/scripts/meson.build +++ b/scripts/meson.build @@ -29,7 +29,6 @@ scripts =3D [ 'meson-timestamp.py', 'mock-noinline.py', 'prohibit-duplicate-header.py', - 'test-wrap-argv.py', ] foreach name : scripts diff --git a/scripts/test-wrap-argv.py b/scripts/test-wrap-argv.py deleted file mode 100755 index 9ec572b479..0000000000 --- a/scripts/test-wrap-argv.py +++ /dev/null @@ -1,168 +0,0 @@ -#!/usr/bin/env python3 -# -# Copyright (C) 2019 Red Hat, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library. If not, see -# . -# -# This script is intended to be passed a list of .args files, used -# to store command line ARGV for the test suites. It will reformat -# them such that there is at most one '-param value' on each line -# of the file. Parameter values that are longer than 80 chars will -# also be split. -# -# If --in-place is supplied as the first parameter of this script, -# the files will be changed in place. -# If --check is the first parameter, the script will return -# a non-zero value if a file is not wrapped correctly. -# Otherwise the rewrapped files are printed to the standard output. - -import argparse -import subprocess -import sys - - -def rewrap_line(line): - bits =3D line.split(" ") - - # bits contains env vars, then the command line - # and then the arguments - env =3D [] - cmd =3D None - args =3D [] - - if "=3D" not in bits[0]: - cmd =3D bits[0] - bits =3D bits[1:] - - for bit in bits: - # If no command is defined yet, we must still - # have env vars - if cmd is None: - # Look for leading / to indicate command name - if bit.startswith("/"): - cmd =3D bit - else: - env.append(bit) - else: - # If there's a leading '-' then this is a new - # parameter, otherwise its a value for the prev - # parameter. - if bit.startswith("-") or len(args) =3D=3D 0: - args.append(bit) - else: - args[-1] =3D args[-1] + " " + bit - - # We might have to split line argument values... - args =3D [rewrap_arg(arg) for arg in args] - - # Print env + command first - return " \\\n".join(env + [cmd] + args) + "\n" - - -def rewrap_arg(arg): - ret =3D [] - max_len =3D 78 - - while len(arg) > max_len: - split =3D arg.rfind(",", 0, max_len + 1) - if split =3D=3D -1: - split =3D arg.rfind(":", 0, max_len + 1) - if split =3D=3D -1: - split =3D arg.rfind(" ", 0, max_len + 1) - if split =3D=3D -1: - print("cannot find nice place to split '%s' below 80 chars" % - arg, file=3Dsys.stderr) - split =3D max_len - 1 - - split =3D split + 1 - - ret.append(arg[0:split]) - arg =3D arg[split:] - - ret.append(arg) - return "\\\n".join(ret) - - -def rewrap(filename, in_place, check): - # Read the original file - with open(filename, 'r') as fh: - orig_lines =3D [] - for line in fh: - orig_lines.append(line) - - if len(orig_lines) =3D=3D 0: - return - - lines =3D [] - for line in orig_lines: - if line.endswith("\\\n"): - line =3D line[:-2] - lines.append(line) - - # Kill the last new line in the file - lines[-1] =3D lines[-1].rstrip("\n") - - # Reconstruct the master data by joining all lines - # and then split again based on the real desired - # newlines - lines =3D "".join(lines).split("\n") - - # Now each 'lines' entry represents a single command, we - # can process them - new_lines =3D [] - for line in lines: - new_lines.append(rewrap_line(line)) - - if in_place: - with open(filename, "w") as fh: - for line in new_lines: - print(line, file=3Dfh, end=3D'') - elif check: - orig =3D "".join(orig_lines) - new =3D "".join(new_lines) - if new !=3D orig: - diff =3D subprocess.Popen(["diff", "-u", filename, "-"], - stdin=3Dsubprocess.PIPE) - diff.communicate(input=3Dnew.encode('utf-8')) - - print("Incorrect line wrapping in '%s'" % - filename, file=3Dsys.stderr) - print("Use test-wrap-argv.py to wrap test data files", - file=3Dsys.stderr) - return False - else: - for line in new_lines: - print(line, end=3D'') - - return True - - -parser =3D argparse.ArgumentParser(description=3D'Test arg line wrapper') -parser.add_argument('--in-place', '-i', action=3D"store_true", - help=3D'modify files in-place') -parser.add_argument('--check', action=3D"store_true", - help=3D'check existing files only') -parser.add_argument('files', nargs=3D"+", - help=3D"filenames to check") -args =3D parser.parse_args() - -errs =3D False -for filename in args.files: - if not rewrap(filename, args.in_place, args.check): - errs =3D True - -if errs: - sys.exit(1) -sys.exit(0) diff --git a/tests/testutils.c b/tests/testutils.c index 3363d7f0aa..0a719bc782 100644 --- a/tests/testutils.c +++ b/tests/testutils.c @@ -325,26 +325,6 @@ virTestLoadFileJSON(const char *p, ...) } -static int -virTestRewrapFile(const char *filename) -{ - g_autofree char *script =3D NULL; - g_autoptr(virCommand) cmd =3D NULL; - - if (!(virStringHasSuffix(filename, ".args") || - virStringHasSuffix(filename, ".argv") || - virStringHasSuffix(filename, ".ldargs"))) - return 0; - - script =3D g_strdup_printf("%s/scripts/test-wrap-argv.py", abs_top_src= dir); - - cmd =3D virCommandNewArgList(PYTHON3, script, "--in-place", filename, = NULL); - if (virCommandRun(cmd, NULL) < 0) - return -1; - - return 0; -} - /** * @param stream: output stream to write differences to * @param expect: expected output text @@ -364,8 +344,7 @@ virTestDifferenceFullInternal(FILE *stream, const char *expectName, const char *actual, const char *actualName, - bool regenerate, - bool rewrap) + bool regenerate) { const char *expectStart; const char *expectEnd; @@ -387,12 +366,6 @@ virTestDifferenceFullInternal(FILE *stream, virDispatchError(NULL); return -1; } - - if (rewrap && - virTestRewrapFile(expectName) < 0) { - virDispatchError(NULL); - return -1; - } } if (!virTestGetDebug()) @@ -457,7 +430,7 @@ virTestDifferenceFull(FILE *stream, const char *actualName) { return virTestDifferenceFullInternal(stream, expect, expectName, - actual, actualName, true, true); + actual, actualName, true); } /** @@ -480,7 +453,7 @@ virTestDifferenceFullNoRegenerate(FILE *stream, const char *actualName) { return virTestDifferenceFullInternal(stream, expect, expectName, - actual, actualName, false, false); + actual, actualName, false); } /** @@ -607,7 +580,7 @@ virTestCompareToFileFull(const char *actual, if (STRNEQ_NULLABLE(cmpcontent, filecontent)) { virTestDifferenceFullInternal(stderr, filecontent, filename, - cmpcontent, NULL, true, unwrap); + cmpcontent, NULL, true); return -1; } --=20 2.30.2