Subject: bug#39357: tests/cp/proc-short-read.sh fails in modern build environment

From: Kamil Dudka <[email-masked]>
Date: Tue, 04 Feb 2020 11:34:00 +0100

On Tuesday, February 4, 2020 1:45:06 AM CET Pádraig Brady wrote:
> On 30/01/2020 13:53, Kamil Dudka wrote:
> > tests/cp/proc-short-read.sh expects that a pair of subsequent reads from
> > /proc/kallsyms will always return the same content.  This does not seem to
> > be a safe assumption any more.  The test has started to fail in our build
> > environment.  I am not sure how to fix the test.  We could probably make
> > it use another file from /proc but most of them are much smaller than
> > kallsyms and/or suffer from the same problem.  Output of the failing test
> > follows.
> > 
> > Kamil
> > 
> > 
> > FAIL: tests/cp/proc-short-read
> > ==============================
> > 
> > + compare_ 1 2
> > + diff -u 1 2
> > --- 1	2020-01-29 12:04:36.923963121 +0000
> > +++ 2	2020-01-29 12:04:37.026963484 +0000
> > @@ -114819,81 +114819,132 @@
> > 
> >   0000000000000000 t nfs_file_direct_read.cold	[nfs]
> >   0000000000000000 t nfs_file_direct_write.cold	[nfs]
> >   0000000000000000 r .LC0	[nfs]
> > 
> > -0000000000000000 r .LC2	[nfs]
> > -0000000000000000 r __ksymtab_nfs_pgio_current_mirror	[nfs]
> > -0000000000000000 r __kstrtab_nfs_pgio_current_mirror	[nfs]
> > 
> > +0000000000000000 r __func__.87038	[nfs]
> > +0000000000000000 t __nfs_revalidate_inode.cold	[nfs]
> > +0000000000000000 t nfs_revalidate_mapping.cold	[nfs]
> > +0000000000000000 d nfs_net_ops	[nfs]
> > +0000000000000000 t exit_nfs_fs	[nfs]
> > +0000000000000000 r __param_enable_ino64	[nfs]
> > +0000000000000000 r __param_str_enable_ino64	[nfs]
> > +0000000000000000 r .LC15	[nfs]
> > +0000000000000000 r __ksymtab_nfs_fs_type	[nfs]
> > +0000000000000000 r __kstrtab_nfs_fs_type	[nfs]
> > 
> > + fail=1
> > + md5sum /proc/kallsyms
> > + md5sum 2
> > + sed 's/ .*//' 3
> > + sed 's/ .*//' 4
> > + compare sum.proc sum.2
> > + compare_dev_null_ sum.proc sum.2
> > + test 2 = 2
> > + test xsum.proc = x/dev/null
> > + test xsum.2 = x/dev/null
> > + return 2
> > + case $? in
> > + compare_ sum.proc sum.2
> > + diff -u sum.proc sum.2
> > --- sum.proc	2020-01-29 12:04:37.172963999 +0000
> > +++ sum.2	2020-01-29 12:04:37.175964009 +0000
> > @@ -1 +1 @@
> > -226cd09830f68c56edda0b9272be66e4
> > +37d7e78173b2a31d5f27cc66aa52e72a
> > + fail=1
> 
> Interesting.
> The attached changes to /proc/cpuinfo
> which is a bit more awkward, but should be a valid test most of the time,
> and is also the file for which the original bug report was against.
> 
> cheers,
> Pádraig

Neither the content of /proc/cpuinfo is guaranteed to be immutable because 
CPUs can go online/offline at run time.  Anyway, the proposed patch has
passed my quick test.  So I think it is an improvement over status quo. 

Thanks!

Kamil