Signed-off-by: Xiaoguang Wang <wangxg.f...@cn.fujitsu.com> --- tools/apicmds/.gitignore | 1 + tools/apicmds/Makefile | 2 +- tools/apicmds/ltpapicmd.c | 31 +++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/tools/apicmds/.gitignore b/tools/apicmds/.gitignore index 0c1a896..0ac3e43 100644 --- a/tools/apicmds/.gitignore +++ b/tools/apicmds/.gitignore @@ -9,3 +9,4 @@ tst_ncpus tst_ncpus_max tst_res tst_resm +tst_fs_has_free diff --git a/tools/apicmds/Makefile b/tools/apicmds/Makefile index 9ecf570..aa3eefe 100644 --- a/tools/apicmds/Makefile +++ b/tools/apicmds/Makefile @@ -27,7 +27,7 @@ include $(top_srcdir)/include/mk/testcases.mk CPPFLAGS += -D_GNU_SOURCE MAKE_TARGETS := $(addprefix tst_,brk brkm exit flush kvercmp kvercmp2 \ - res resm ncpus ncpus_max get_unused_port) + res resm ncpus ncpus_max get_unused_port fs_has_free) include $(top_srcdir)/include/mk/generic_leaf_target.mk diff --git a/tools/apicmds/ltpapicmd.c b/tools/apicmds/ltpapicmd.c index c8099c5..5f9c582 100644 --- a/tools/apicmds/ltpapicmd.c +++ b/tools/apicmds/ltpapicmd.c @@ -73,6 +73,7 @@ #include <stdio.h> #include <string.h> #include <stdlib.h> +#include <stdint.h> #include "test.h" #include "usctest.h" #include "safe_macros.h" @@ -324,6 +325,33 @@ err: exit(1); } +int apicmd_fs_has_free(int argc, char *argv[]) +{ + int ret = 2; + + if (argc != 3) { + fprintf(stderr, "Usage: tst_fs_has_free path required_kib\n" + "path: the pathname of any file within the mounted " + "filesystem\n required_kib: the required free space" + "(count in KB)\n"); + goto fs_has_free_err; + } + + char *endptr; + uint64_t required_kib = strtoull(argv[1], &endptr, 0); + + if (*argv[1] == '\0' || *endptr != '\0') { + fprintf(stderr, "%s is not a valid numeric string\n", argv[1]); + goto fs_has_free_err; + } + + ret = tst_fs_has_free(NULL, argv[0], required_kib, TST_KB); + ret = 1 ^ ret; + +fs_has_free_err: + exit(ret); +} + /* * Function: main - entry point of this program * @@ -359,6 +387,7 @@ int main(int argc, char *argv[]) if (TCID == NULL || tst_total == NULL || tst_cntstr == NULL) { if (!strcmp(cmd_name, "tst_kvercmp") && !strcmp(cmd_name, "tst_kvercmp2") && + !strcmp(cmd_name, "tst_fs_has_free") && !strcmp(cmd_name, "tst_get_unused_port")) { fprintf(stderr, "\nSet variables TCID, TST_TOTAL, and TST_COUNT before each test:\n" @@ -409,6 +438,8 @@ int main(int argc, char *argv[]) printf("%li\n", tst_ncpus_max()); } else if (strcmp(cmd_name, "tst_get_unused_port") == 0) { printf("%u\n", apicmd_get_unused_port(argc, argv)); + } else if (strcmp(cmd_name, "tst_fs_has_free") == 0) { + apicmd_fs_has_free(argc, argv); } exit(0); -- 1.8.2.1 ------------------------------------------------------------------------------ Start Your Social Network Today - Download eXo Platform Build your Enterprise Intranet with eXo Platform Software Java Based Open Source Intranet - Social, Extensible, Cloud Ready Get Started Now And Turn Your Intranet Into A Collaboration Platform http://p.sf.net/sfu/ExoPlatform _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list