[LTP] [PATCH v3] Add stat04 test
Cyril Hrubis
chrubis@suse.cz
Wed Feb 21 15:52:58 CET 2024
Hi!
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
> + * Author: David Fenner
> + * Copilot: Jon Hendrickson
> + * Copyright (C) 2024 Andrea Cervesato <andrea.cervesato@suse.com>
> + */
> +
> +/*\
> + * [Description]
> + *
> + * This test checks that stat() executed on file provide the same information
> + * of symlink linking to it.
> + */
> +
> +#include "tst_test.h"
> +
> +static void run(void)
> +{
> + char *symname = "my_symlink0";
> + char *tmpdir = tst_get_tmpdir();
This is stil a memory leak. I guess that the test will allocate huge
amount of memory with large enough -i parameter.
Either call it once in the test setup() or use "." instead.
> + SAFE_SYMLINK(tmpdir, symname);
> +
> + struct stat path_stat;
> + struct stat link_stat;
I guess that the output of the comparsions below would look better if we
call these variables just path and link.
> + TST_EXP_PASS(stat(tmpdir, &path_stat));
> + TST_EXP_PASS(stat(symname, &link_stat));
> +
> + TST_EXP_EQ_LI(path_stat.st_dev, link_stat.st_dev);
> + TST_EXP_EQ_LI(path_stat.st_mode, link_stat.st_mode);
> + TST_EXP_EQ_LI(path_stat.st_nlink, link_stat.st_nlink);
> + TST_EXP_EQ_LI(path_stat.st_uid, link_stat.st_uid);
> + TST_EXP_EQ_LI(path_stat.st_gid, link_stat.st_gid);
> + TST_EXP_EQ_LI(path_stat.st_size, link_stat.st_size);
> + TST_EXP_EQ_LI(path_stat.st_atime, link_stat.st_atime);
> + TST_EXP_EQ_LI(path_stat.st_mtime, link_stat.st_mtime);
> + TST_EXP_EQ_LI(path_stat.st_ctime, link_stat.st_ctime);
> +
> + SAFE_UNLINK(symname);
> +}
> +
> +static struct tst_test test = {
> + .test_all = run,
> + .needs_tmpdir = 1,
> +};
> --
> 2.35.3
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list