[LTP] [PATCH v1 1/2] syscalls/fstat{01,02}: rewrote testcases

Cyril Hrubis chrubis@suse.cz
Tue May 28 16:03:35 CEST 2019


Hi!
> +++ b/testcases/kernel/syscalls/fstat/fstat.h
> @@ -0,0 +1,34 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (c) SUSE LLC, 2019
> + * Author: Christian Amann <camann@suse.com>
> + */
> +
> +#ifndef __FSTAT_H__
> +#define __FSTAT_H__
> +
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <unistd.h>
> +#include "lapi/syscalls.h"
> +
> +#define TEST_VARIANTS	2
> +#define TESTFILE	"test_file"
> +
> +static void syscall_info(void)
> +{
> +	if (tst_variant == 0) {
> +		tst_res(TINFO, "Testing libc fstat()");
> +		return;
> +	}
> +	tst_res(TINFO, "Testing syscall fstat()");
> +}
> +
> +static int tst_fstat(int fd, struct stat *statbuf)
> +{
> +	if (tst_variant == 0)
> +		return fstat(fd, statbuf);
> +	return tst_syscall(__NR_fstat, fd, statbuf);
> +}

Have you tested this wrapper with 32bit binary?

Because on x86 (among others) we do have fstat and fstat64 that differ
in the statbuf structure size (see man fstat NOTES). If I add a printf()
to print sizeof(struct stat) to the fstat01.c test on x86 I get 96 bytes
with _FILE_OFFSET_BITS=64 and 88 without, so I guess that this uses
wrong syscall with the _FILE_OFFSET_BITS=64 defined.

And actually there are three fstat variants there, the old_fstat, fstat
and fstat64, we could probably test all three variants but I guess that
old_fstat is actually not worth of the effort...

HINT: You can compile 32bit LTP on 64bit distribution with:
      ./configure CFLAGS=-m32 LDFLAGS=-m32.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list