Signed-off-by: Xiaoguang Wang <wangxg.f...@cn.fujitsu.com>
---
 tools/apicmds/.gitignore  |  1 +
 tools/apicmds/Makefile    |  2 +-
 tools/apicmds/ltpapicmd.c | 26 ++++++++++++++++++++++++++
 3 files changed, 28 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..de58c1e 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,28 @@ err:
        exit(1);
 }
 
+int apicmd_fs_has_free(int argc, char *argv[])
+{
+       if (argc != 3)
+               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;
+       }
+
+       return tst_fs_has_free(NULL, argv[0], required_kib);
+
+fs_has_free_err:
+       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");
+       exit(1);
+}
+
 /*
  * Function:    main - entry point of this program
  *
@@ -359,6 +382,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 +433,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) {
+               printf("%d\n", apicmd_fs_has_free(argc, argv));
        }
 
        exit(0);
-- 
1.8.2.1


------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment 
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to