[LTP] [PATCH v3 1/4] Add stat04 test

Cyril Hrubis chrubis@suse.cz
Wed Jul 10 14:15:46 CEST 2024


Hi!
> +static char symb_path[PATH_MAX];
> +static char file_path[PATH_MAX];
> +static struct stat *file_stat;
> +static struct stat *symb_stat;
> +static char *tmpdir;
> +
> +static void run(void)
> +{
> +	SAFE_STAT(file_path, file_stat);
> +	SAFE_STAT(symb_path, symb_stat);
> +
> +	TST_EXP_EQ_LI(file_stat->st_dev, symb_stat->st_dev);
> +	TST_EXP_EQ_LI(file_stat->st_mode, symb_stat->st_mode);
> +	TST_EXP_EQ_LI(file_stat->st_nlink, symb_stat->st_nlink);
> +	TST_EXP_EQ_LI(file_stat->st_uid, symb_stat->st_uid);
> +	TST_EXP_EQ_LI(file_stat->st_gid, symb_stat->st_gid);
> +	TST_EXP_EQ_LI(file_stat->st_size, symb_stat->st_size);
> +	TST_EXP_EQ_LI(file_stat->st_atime, symb_stat->st_atime);
> +	TST_EXP_EQ_LI(file_stat->st_mtime, symb_stat->st_mtime);
> +	TST_EXP_EQ_LI(file_stat->st_ctime, symb_stat->st_ctime);
> +}
> +
> +static void setup(void)
> +{
> +	char opt_bsize[32];
> +	const char *const fs_opts[] = {opt_bsize, NULL};
> +	struct stat sb;
> +	int pagesize;
> +	int fd;
> +
> +	tmpdir = tst_get_tmpdir();
> +
> +	if (strlen(tmpdir) >= (PATH_MAX - strlen(FILENAME))) {
> +		tst_brk(TCONF, "Temporary folder name is too long. "
> +			"Can't create file");
> +	}
> +
> +	if (strlen(tmpdir) >= (PATH_MAX - strlen(SYMBNAME))) {
> +		tst_brk(TCONF, "Temporary folder name is too long. "
> +			"Can't create symbolic link");
> +	}

Uff, this is so 1990. Can we please use asprintf() instead?


Other than that this looks good to me:

Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list