From patchwork Wed Dec 11 01:11:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: DJ Delorie X-Patchwork-Id: 1207338 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-107938-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="clF6EZpX"; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="XLAoAS8n"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47Xf5G5bSjz9sP6 for ; Wed, 11 Dec 2019 12:11:14 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:message-id:from:to:subject:content-type :content-transfer-encoding; q=dns; s=default; b=lVQcL5WAgYq8jSAw bKvXZEPL5fXXPYIXAhomNF7JvoN4CnmwlaF22zWHiIy4NWSKnDrYiDtmFoV/Ic8k L0czlvA0vKY9nfKEdGUiyPKJYDBjskwRTNs6NcE7e0KE+QoqaRYlXYgszZKO9F0M jKJWJkpvgnamStNOpB5a3OKi4n4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:message-id:from:to:subject:content-type :content-transfer-encoding; s=default; bh=qRl2djLSdrHyp77zGU8LSD XFRm8=; b=clF6EZpXFkGs3EbkL22uq9+qkeutBVgofL3r7ZhheCfSo6Ae5bhMWp 5f1ZCyzB8iyIrta9yDUggQQYUABreSVHI368wJe4TSVYkgyd0ULf7fgPyjRy3Gi8 X/ReyftZ6lz91MiQRug7k9s1/KowZnDwTiwzsPVudCm/5jxjypXxs= Received: (qmail 73656 invoked by alias); 11 Dec 2019 01:11:07 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 73647 invoked by uid 89); 11 Dec 2019 01:11:07 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy=fresh X-HELO: us-smtp-delivery-1.mimecast.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576026664; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jLDgUTomVNQZdb9IDbKoQ9ZVdUEf13Gyl/pR58IPNXM=; b=XLAoAS8nyl+yc/o6UysWJ+PiGp9gxVVeWi/NKsuWKmYFDLuJ0ZRss7flxGK8Hu2A0OdU7D TcEv2p77SI2h9+1uQw143iLg1QUhaxRzhI1zx5nOzQ5UF+3ZD93dWhEqlfxL1jPLpUJywi zvm1EgmUnJHwnhleI7x725uxzMk7SWI= Date: Tue, 10 Dec 2019 20:11:00 -0500 Message-Id: From: DJ Delorie To: libc-alpha@sourceware.org Subject: test-container: ability to specify exec path X-Mimecast-Spam-Score: 0 Carlos asked for something like this for $ORIGIN testing... diff --git a/nss/tst-nss-test3.root/tst-nss-test3.script b/nss/tst-nss-test3.root/tst-nss-test3.script index a10beb1e6c..03ba5c5276 100644 --- a/nss/tst-nss-test3.root/tst-nss-test3.script +++ b/nss/tst-nss-test3.root/tst-nss-test3.script @@ -1,2 +1,3 @@ cp $B/nss/libnss_test1.so $L/libnss_test1.so.2 cp $B/nss/libnss_test2.so $L/libnss_test2.so.2 +exec /usr/bin/foo diff --git a/support/test-container.c b/support/test-container.c index 5d08979df3..d4ecfe8a98 100644 --- a/support/test-container.c +++ b/support/test-container.c @@ -95,6 +95,7 @@ int verbose = 0; mv FILE FILE cp FILE FILE rm FILE + exec PATH FILE must start with $B/, $S/, $I/, $L/, or / (expands to build dir, source dir, install dir, library dir (in container), or container's root) @@ -104,6 +105,7 @@ int verbose = 0; - 'mv': A minimal move files command. - 'cp': A minimal copy files command. - 'rm': A minimal remove files command. + - 'exec': change where test is run from (may end in /) * mytest.root/postclean.req causes fresh rsync (with delete) after test if present @@ -868,7 +870,9 @@ main (int argc, char **argv) the_words[i] = concat (new_root_path, support_libdir_prefix, the_words[i] + 2, NULL); - else if (the_words[i][0] == '/') + /* "exec" uses inside-root paths. */ + else if (strcmp (the_words[0], "exec") != 0 + && the_words[i][0] == '/') the_words[i] = concat (new_root_path, the_words[i], NULL); } @@ -912,6 +916,33 @@ main (int argc, char **argv) { maybe_xunlink (the_words[1]); } + else if (nt == 2 && strcmp (the_words[0], "exec") == 0) + { + char *new_exec_path = the_words[1]; + char *test_basename = new_child_proc[0]; + + /* Find the base name of the test. */ + if (strrchr (test_basename, '/') != NULL) + test_basename = strrchr (test_basename, '/') + 1; + + /* If the new exec path ends with a slash, that's the + * directory, and use the old test base name. */ + if (new_exec_path [strlen(new_exec_path) - 1] == '/') + new_exec_path = concat (new_exec_path, + test_basename, + NULL); + + + /* new_child_proc is in the build tree, so has the + same path inside the chroot as outside. The new + exec path is, by definition, relative to the + chroot. */ + copy_one_file (new_child_proc[0], concat (new_root_path, + new_exec_path, + NULL)); + + new_child_proc[0] = strdup (new_exec_path); + } else if (nt == 1 && strcmp (the_words[0], "su") == 0) { be_su = 1;