NetBSD Problem Report #49224

From www@NetBSD.org  Fri Sep 19 21:37:56 2014
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id CB759A6775
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 19 Sep 2014 21:37:56 +0000 (UTC)
Message-Id: <20140919213755.912E7A679B@mollari.NetBSD.org>
Date: Fri, 19 Sep 2014 21:37:55 +0000 (UTC)
From: yaneurabeya@gmail.com
Reply-To: yaneurabeya@gmail.com
To: gnats-bugs@NetBSD.org
Subject: [PATCH] Checking for uname in usr.bin/grep/tests/t_grep:binary is still not 100% reliable if branded OS name doesn't match ELF binary branding
X-Send-Pr-Version: www-1.0

>Number:         49224
>Category:       bin
>Synopsis:       [PATCH] Checking for uname in usr.bin/grep/tests/t_grep:binary is still not 100% reliable if branded OS name doesn't match ELF binary branding
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Sep 19 21:40:01 +0000 2014
>Closed-Date:    Mon Aug 14 01:41:18 +0000 2017
>Last-Modified:  Mon Aug 14 01:41:18 +0000 2017
>Originator:     Garrett Cooper
>Release:        n/a
>Organization:
EMC / Isilon Storage Division
>Environment:
n/a
>Description:
The fix I described in PR/47825 addressed the simple case of FreeBSD vs NetBSD, but it doesn't address the larger issue with /bin/sh being grep'ed for ELF branding information.

What I did instead (because I'm working for a company that rebrands FreeBSD as another OS), is I modified the test again to instead generate binary output, echo foobar out to the output, then grep for the expected output. This change will make the testcase robust in all cases.

$ svn diff t_grep.sh
Index: t_grep.sh
===================================================================
--- t_grep.sh   (revision 437720)
+++ t_grep.sh   (working copy)
@@ -43,7 +43,10 @@
 }
 binary_body()
 {
-       atf_check -o file:"$(atf_get_srcdir)/d_binary.out" grep $(uname) /bin/sh
+       dd if=/dev/random count=1 of=test.file
+       echo -n "foobar" >> test.file
+       atf_check -o file:"$(atf_get_srcdir)/d_binary.out" grep foobar test.file
 }

 atf_test_case recurse
$ svn diff d_binary.out
Index: d_binary.out
===================================================================
--- d_binary.out        (revision 437720)
+++ d_binary.out        (working copy)
@@ -1 +1 @@
-Binary file /bin/sh matches
+Binary file test.file matches
>How-To-Repeat:

>Fix:

>Release-Note:

>Audit-Trail:

State-Changed-From-To: open->closed
State-Changed-By: ginsbach@NetBSD.org
State-Changed-When: Mon, 14 Aug 2017 01:41:18 +0000
State-Changed-Why:
christos committed idential change for PR/51875.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.