[LTP] [PATCH 5/5] dup05.c: use TST_EXP_FD() macro and make check fixes

Petr Vorel pvorel@suse.cz
Mon May 29 20:20:35 CEST 2023


Hi Avinesh,

I slightly modified some of the commits and merged the patchset.
Thanks!

> + update copyright.
> + use SAFE_OPEN() and SAFE_CLOSE()


...
>  /*\
> - * [DESCRIPTION]
> + * [Description]
+1

>   *
>   * Basic test for dup(2) of a named pipe descriptor
>   */
> -#include <stdio.h>
> +
>  #include "tst_test.h"

> -char Fname[255];
> -int fd;
> +#define Fname "dupfile"
FYI I renamed to FNAME (don't hesitate to rename constants which aren't
lowercase or variables with very long name (expected_errno => exp_err - used
widely in LTP).

> +
> +static int fd;

>  static void run(void)
>  {
> -	TEST(dup(fd));
> -
> -	if (TST_RET == -1) {
> -		tst_res(TFAIL | TTERRNO, "dup failed");
> -	} else {
> -		tst_res(TPASS, "dup returned %ld",
> -			 TST_RET);
> -
> -		SAFE_CLOSE(TST_RET);
> -	}
> +	TST_EXP_FD(dup(fd), "dup(%d)", fd);
> +	SAFE_CLOSE(TST_RET);
>  }

> -void setup(void)
> +static void setup(void)
>  {
>  	fd = -1;
FYI I moved -1 to declaration:
static int fd = -1;

Kind regards,
Petr


More information about the ltp mailing list