bugGNU roff - Bugs: bug #58165, "nroff -V ..." tests...

 
 

bug #58165: "nroff -V ..." tests fail for other devices than "ascii"

Submitter:  Bjarni Ingi Gislason <bjarniig>
Submitted:  Sun 12 Apr 2020 08:37:06 PM UTC
   
 
Category:  Core Severity:  3 - Normal
Item Group:  Test Status:  Invalid
Privacy:  Public Assigned to:  gbranden
Open/Closed:  Closed Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 13 Apr 2020 10:43:06 PM UTC, comment #9: 

I'm resolving this.  With my recent commits it is much easier to demonstrate that the proposition in the original report is false.

Here's nroff -V working in a latin1 environment.  I launched an xterm using "LC=en_US xterm -lc".


[build groff from git HEAD]
$ cd build
$ GROFF_TEST_GROFF=./test-groff ./nroff -v
GNU nroff (groff) version 1.22.4.174-c590
GNU groff version 1.22.4.174-c590
Copyright (C) 2018 Free Software Foundation, Inc.
GNU groff comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of groff and its subprograms
under the terms of the GNU General Public License.
For more information about these matters, see the file
named COPYING.

called subprograms:

GNU grotty (groff) version 1.22.4.174-c590
GNU troff (groff) version 1.22.4.174-c590
$ locale charmap
ISO-8859-1
$ GROFF_TEST_GROFF=./test-groff ./nroff -V
PATH=... ./test-groff -Tlatin1 -mtty-char


And of course it works in a UTF-8 environment, which is what I normally use:


$ cd build
$ GROFF_TEST_GROFF=./test-groff nroff -v
GNU nroff (groff) version 1.22.4
$ GROFF_TEST_GROFF=./test-groff ./nroff -v
GNU nroff (groff) version 1.22.4.174-c590
GNU groff version 1.22.4.174-c590
Copyright (C) 2018 Free Software Foundation, Inc.
GNU groff comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of groff and its subprograms
under the terms of the GNU General Public License.
For more information about these matters, see the file
named COPYING.

called subprograms:

GNU grotty (groff) version 1.22.4.174-c590
GNU troff (groff) version 1.22.4.174-c590
$ locale charmap
UTF-8
$ GROFF_TEST_GROFF=./test-groff ./nroff -V
PATH=... ./test-groff -Tutf8 -mtty-char


I am resolving this as "invalid" rather than "fixed" because I didn't actually change the nroff script with respect to device determination.  I believe I have, however, made it easier to forensically analyze an nroff inside the build tree prior to installation.

The following commits are relevant to that work, in forward chronological order:


commit e44b590c872aa7d334cfceab0b40ac7291684541
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Mon Apr 13 21:33:19 2020 +1000

    Catch nroff/groff version desync.

    Note that this commit will likely lead to a failing test case (but
    perhaps not, if your build environment lacks a system groff).

    It's too easy for the nroff version to get desynced from the groff
    version when we're running test cases, leading to spurious results.
    Make it easier to see a discrepancy.

    * src/roff/nroff/nroff.sh: Call groff with -v or --version when we are
      called that way.

    * src/roff/nroff/tests/verbose_option_works.sh.in: Check the nroff
      version being tested against the groff version being wrapped.  This
      exposes a bug; the system groff rather than the build tree groff was
      being invoked.

    Also delete an old comment in nroff.sh.  The file uses the Stephen
    Bourne "brace style" now, so the issue is unlikely to recur.

commit 2a9e09c0331c5ecca5fe0c3ee7f12dc93c547553
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Mon Apr 13 22:30:05 2020 +1000

    Repair nroff test case.

    * src/roff/nroff/nroff.sh: Let test cases tell us to use test-groff as
      groff with an environment variable.

    * src/roff/nroff/tests/verbose_option_works.sh.in: Refactor.  Stop
      messing with @GROFF_BIN_PATH_SETUP@; instead, let test-groff handle
      that for us.  Locate it and export the variable GROFF_TEST_GROFF so
      nroff can find it.  Because we manipulate $PATH to run the tests, the
      $PATH of an installed groff system will _always_ differ from that used
      by a build tree; ignore it in the test cases.  Dispose of bashisms and
      set shebang to /bin/sh.

    I have more confidence in the test script now.  Does anyone else?

    $ cat build/src/roff/nroff/tests/verbose_option_works.sh.log
    nroff: 1.22.4.169-e44b5
    groff: 1.22.4.169-e44b5
    testing 'nroff -V'
    test-groff -Tascii -mtty-char
    testing 'nroff -V 1'
    test-groff -Tascii -mtty-char 1
    testing 'nroff -V "1a 1b"'
    test-groff -Tascii -mtty-char "1a 1b"
    testing 'nroff -V "1a 1b" 2'
    test-groff -Tascii -mtty-char "1a 1b" 2
    testing 'nroff -V 1a\"1b 2'
    test-groff -Tascii -mtty-char 1a"1b 2
    PASS src/roff/nroff/tests/verbose_option_works.sh (exit status: 0)


Resolving.

G. Branden Robinson <gbranden>
Group administrator
Mon 13 Apr 2020 04:34:20 PM UTC, comment #8: 

1) My sentence can be interpreted in two ways,

more clearly:

I added the line

unset LESSCHARSET

to the script, as nroff checked for that case.

  my environment has the variable defined with

LESSCHARSET=latin1
 
2) Add the line

export GROFF_TYPESETTER=ascii

to override a possible default value.

2) The test script contains the line

export LC_ALL=C

   so a natural test is to check, how that affects the working of the
"nroff" script, in this case of "locale charmap".
 
  The available locales on my computer are:

locale -a

C
C.UTF-8
icelandic
is_IS
is_IS.iso88591
is_IS.utf8
POSIX

  I think the C locale is standard in GNU systems and thus always
available.

git version 2.25.1 (Debian testing)
 
  The "nroff.sh" and "nroff.am" scripts have not been changed by me,
but I create a "test-nroff" from them with a "test-nroff.am" file, which
is based on the "nroff.am" file.


Bjarni Ingi Gislason <bjarniig>
Mon 13 Apr 2020 01:28:29 PM UTC, comment #7: 


comment #6:

>
>   I looked at the issue again.
>
> 1) unset the LESSCHARSET environmental variable in the test script.


That doesn't sound like anything that's ever been part of the test script.  I'm the only one who's ever committed to it and I'm pretty sure.

It would be helpful if you'd try to reproduce problems against stock, unmodified groffs when filing bugs.  Telling us which git revision you're testing wouldn't hurt either.

>   Result: correct operation.


That's good to hear but a little puzzling. LESSCHARSET is a very distant fallback.  For it to be consulted, all locale checks have to fail.

>
> 2) looked at the first case test with "locale charmap" in "nroff".
>
>   Issued "LC_ALL=C locale charmap".
>
>   Result: ANSI_X3.4-1968


Yes, that's what you should get.
 

>   This shows that the real culprit is a missing case candidate in the
> first case test, not the LESSCHARSET, nor the result of the "locale" I
> use in the environment.
>
>   "groff" supports four output devices, so one is missing in the first
> case test.


I don't follow any of your reasoning here.

1. When your locale is is_IS.ISO-8559-1, "locale charmap" will return "ISO-8859-1" unless you override the command's environment, as in case 2 below.

2. When you run "LC_ALL=C locale charmap", you will always get back ANSI_X3.4-1968".

3. You seem to have a system with a functioning locale system, so I don't see why nroff would ever fall back to LESSCHARSET for you.  Unless you're once again doing something you haven't disclosed, like "LESSCHARSET=latin1 LC_ALL=C nroff".  In that scenario, nroff will attempt to use the latin1 device and it is working exactly as documented in the man page.

I believe I've resolved the problems here with my latest commits to nroff and its test script, but I'll give it a few minutes before resolving the ticket because I need to catch up on mail.

>   A case of wrong conclusions, suggestions is seen in the bug
> report #58098.

G. Branden Robinson <gbranden>
Group administrator
Mon 13 Apr 2020 12:36:59 PM UTC, comment #6: 


  I looked at the issue again.

1) unset the LESSCHARSET environmental variable in the test script.

  Result: correct operation.

2) looked at the first case test with "locale charmap" in "nroff".

  Issued "LC_ALL=C locale charmap".

  Result: ANSI_X3.4-1968

  This shows that the real culprit is a missing case candidate in the
first case test, not the LESSCHARSET, nor the result of the "locale" I
use in the environment.

  "groff" supports four output devices, so one is missing in the first
case test.

  A case of wrong conclusions, suggestions is seen in the bug
report #58098.

Bjarni Ingi Gislason <bjarniig>
Mon 13 Apr 2020 08:51:48 AM UTC, comment #5: 

Here's some more stuff that works for me.


$ GROFF_RUNTIME="${GROFF_BIN_PATH=.}:" ./nroff -V
PATH=/usr/local/bin:/home/branden/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/games:/usr/games groff -Tlatin1 -mtty-char
$ GROFF_RUNTIME="${GROFF_BIN_PATH=.}:" ./nroff /tmp/sister.ascii
A møøse once bið my sisþer...
$ GROFF_RUNTIME="${GROFF_BIN_PATH=.}:" ./nroff /tmp/sister.latin1
A møøse once bið my sisþer...
$ locale
LANG=C
LANGUAGE=
LC_CTYPE="is_IS.ISO-8859-1"
LC_NUMERIC="is_IS.ISO-8859-1"
LC_TIME="is_IS.ISO-8859-1"
LC_COLLATE="is_IS.ISO-8859-1"
LC_MONETARY="is_IS.ISO-8859-1"
LC_MESSAGES="is_IS.ISO-8859-1"
LC_PAPER="is_IS.ISO-8859-1"
LC_NAME="is_IS.ISO-8859-1"
LC_ADDRESS="is_IS.ISO-8859-1"
LC_TELEPHONE="is_IS.ISO-8859-1"
LC_MEASUREMENT="is_IS.ISO-8859-1"
LC_IDENTIFICATION="is_IS.ISO-8859-1"
LC_ALL=is_IS.ISO-8859-1


I'm attaching the input files as exhibits.  One is ASCII-encoded and uses groff character escapes; the other is encoded in ISO 8859-1.

(file #48826, file #48827)

G. Branden Robinson <gbranden>
Group administrator
Mon 13 Apr 2020 08:36:10 AM UTC, comment #4: 

I configured my system to compile the 8-bit Icelandic locale, and I simply cannot reproduce this with the stock test.


$ locale
LANG=C
LANGUAGE=
LC_CTYPE="is_IS.ISO-8859-1"
LC_NUMERIC="is_IS.ISO-8859-1"
LC_TIME="is_IS.ISO-8859-1"
LC_COLLATE="is_IS.ISO-8859-1"
LC_MONETARY="is_IS.ISO-8859-1"
LC_MESSAGES="is_IS.ISO-8859-1"
LC_PAPER="is_IS.ISO-8859-1"
LC_NAME="is_IS.ISO-8859-1"
LC_ADDRESS="is_IS.ISO-8859-1"
LC_TELEPHONE="is_IS.ISO-8859-1"
LC_MEASUREMENT="is_IS.ISO-8859-1"
LC_IDENTIFICATION="is_IS.ISO-8859-1"
LC_ALL=is_IS.ISO-8859-1
$ bash src/roff/nroff/tests/verbose_option_works.sh
testing 'nroff -V'
testing 'nroff -V 1'
testing 'nroff -V "1a 1b"'
testing 'nroff -V "1a 1b" 2'
testing 'nroff -V 1a\"1b 2'
$ echo $?
0


I can get 'latin1' in the output of nroff -V if I try to run pieces of the test script in isolation, and forget to set LC_ALL:


$ GROFF_RUNTIME="${GROFF_BIN_PATH=.}:" ./nroff -V
PATH=/usr/local/bin:/home/branden/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/games:/usr/games groff -Tlatin1 -mtty-char
$ LC_ALL=C GROFF_RUNTIME="${GROFF_BIN_PATH=.}:" ./nroff -V
PATH=/usr/local/bin:/home/branden/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/games:/usr/games groff -Tascii -mtty-char


In the above, my current working directory is the "build/" subdirectory of a groff git checkout.

I suspect your problem is arising from extracting pieces of the test script and failing to prepare the locale in conformance with its expectations.

I also strongly encourage you to migrate every Unix system under your control to UTF-8.

G. Branden Robinson <gbranden>
Group administrator
Mon 13 Apr 2020 02:13:29 AM UTC, comment #3: 

Subject: test-suite: "nroff -V ..." fails for other devices than "ascii"

  Sorry, I too often seem to neglect to provide relevant data.
 I sometimes post findings before I test myself the matter further.
 So you could wait for me providing more data when you ask for it.

1)  First part of the test in the build directory:


# Ensure a predictable character encoding.
export LC_ALL=C
# Ensure a predictable command search path.

GROFF_RUNTIME="${GROFF_BIN_PATH=/usr/local/bin}:"

nroff="${abs_top_builddir:-.}/nroff"

echo "testing 'nroff -V'" >&2
expected="PATH=$GROFF_RUNTIME$PATH groff -Tascii -mtty-char"
actual=$("$nroff" -V)
diff -u <(echo "$expected") <(echo "$actual")

####

  Result:

testing 'nroff -V'
--- /dev/fd/63  2020-04-13 01:11:32.936490725 +0000
+++ /dev/fd/62  2020-04-13 01:11:32.936490725 +0000
@@ -1 +1 @@
-PATH=/usr/local/bin:/home/bg/bin:/home/bg/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/sbin:/usr/sbin:/sbin
 groff -Tascii -mtty-char
+PATH=/usr/local/bin:/home/bg/bin:/home/bg/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/sbin:/usr/sbin:/sbin
 groff -Tlatin1 -mtty-char

####

  Comment:

 Added code to get the version of the nroff and the groff.
 It was at first the version from Debian in /usr/bin/.

 After changes, nroff was the latest in my build directory.

 I do not install the software after each compilation.

  My locale:

LANG=is_IS.iso88591
LANGUAGE=
LC_CTYPE="is_IS.iso88591"
LC_NUMERIC="is_IS.iso88591"
LC_TIME="is_IS.iso88591"
LC_COLLATE="is_IS.iso88591"
LC_MONETARY="is_IS.iso88591"
LC_MESSAGES="is_IS.iso88591"
LC_PAPER="is_IS.iso88591"
LC_NAME="is_IS.iso88591"
LC_ADDRESS="is_IS.iso88591"
LC_TELEPHONE="is_IS.iso88591"
LC_MEASUREMENT="is_IS.iso88591"
LC_IDENTIFICATION="is_IS.iso88591"
LC_ALL=


  My charmap: ISO-8859-1


  The make target "check" is not the same as the GNU standard (Debian
 version is out of date) mentions:

'check'
     Perform self-tests (if any).  The user must build the program
     before running the tests, but need not install the program; you
     should write the self-tests so that they work when the program is
     built but not installed.
 

  There is also a "installcheck" named in the standard,
 but it is empty in the Makefile of groff.


Suggestions:

  Add the version of the used commands to the output of the tests.

  Make "make check" work with the compiled versions in the build
directory.

N.B.

  Neither pre- nor post-processors are shown in the output of
"nroff -V ...".

  I expect that the same option in nroff and groff mean the same.

Bjarni Ingi Gislason <bjarniig>
Sun 12 Apr 2020 10:13:16 PM UTC, comment #2: 

I took a guess at understanding your problem and cannot reproduce it.  Locale detection is working as documented, as far as I can tell.


$ PATH=.:$PATH ./nroff -V -Tascii
PATH=... groff -Tascii -mtty-char
$ PATH=.:$PATH ./nroff -V -Tlatin1
PATH=... groff -Tlatin1 -mtty-char
$ PATH=.:$PATH ./nroff -V -Tcp1047
PATH=... groff -Tcp1047 -mtty-char
$ PATH=.:$PATH ./nroff -V -Tutf8
PATH=... groff -Tutf8 -mtty-char
$ PATH=.:$PATH ./nroff -V
PATH=... groff -Tutf8 -mtty-char
$ LC_ALL=C PATH=.:$PATH ./nroff -V
PATH=... groff -Tascii -mtty-char
$ LC_ALL=C.UTF-8 PATH=.:$PATH ./nroff -V
PATH=... groff -Tutf8 -mtty-char


I need you to specify exactly what your test case was to be able to do anything about this.

Please attach the output of the "locale" command on your failing test environment, the body of the (presumably altered) test script, and the output it produces.

G. Branden Robinson <gbranden>
Group administrator
Sun 12 Apr 2020 10:03:43 PM UTC, comment #1: 


original submission:

> Subject: test-suite: "nroff -V ..." fails for other devices than "ascii"
>
>   All test cases in "src/roff/nroff/tests/verbose_option_works.sh" fail
> with the "latin1" output device.
>
>   "nroff" can use the output devices ascii, cp1047, latin1, and utf8.


I take it you are modifying the test case?

>   Neither pre- nor post-processors are shown in the output of
> "nroff -V ...".


nroff doesn't know what they are; only groff (the command) does.

G. Branden Robinson <gbranden>
Group administrator
Sun 12 Apr 2020 08:37:06 PM UTC, original submission:  

Subject: test-suite: "nroff -V ..." fails for other devices than "ascii"

  All test cases in "src/roff/nroff/tests/verbose_option_works.sh" fail
with the "latin1" output device.

  "nroff" can use the output devices ascii, cp1047, latin1, and utf8.

N.B.

  Neither pre- nor post-processors are shown in the output of
"nroff -V ...".


Bjarni Ingi Gislason <bjarniig>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #48826:  sister.ascii added by gbranden (49B - application/octet-stream)
file #48827:  sister.latin1 added by gbranden (37B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by gbranden (Posted a comment)
  • -email is unavailable- added by bjarniig (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-06-10 gbranden Summarytest-suite: &quot;nroff -V ...&quot; fails for other devices than &quot;ascii&quot; "nroff -V ..." tests fail for other devices than "ascii"
    2020-04-13 gbranden StatusNeed Info Invalid
        Open/ClosedOpen Closed
    2020-04-13 gbranden Attached File- Added sister.ascii, #48826
        Attached File- Added sister.latin1, #48827
    2020-04-12 gbranden StatusNone Need Info
        Assigned toNone gbranden

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code