From: Caspar Z. <su...@li...> - 2011-12-28 08:12:10
|
The branch, master, has been updated via ef2c051655f756104723bb344449e7f1cba528ea (commit) from 3fa874a9b4b2d24369a27e78bd6a36931be06c03 (commit) - Log ----------------------------------------------------------------- commit ef2c051655f756104723bb344449e7f1cba528ea Author: Caspar Zhang <ca...@ca...> Date: Wed Dec 28 16:01:40 2011 +0800 mem/lib: make sys_file use as file instead of path Original design was to pass full path to set/get_sys_tune() but it seems like we'd better keep sys_file paramter filenames only. Reported-by: Wanlong Gao <gao...@cn...> Signed-off-by: Caspar Zhang <ca...@ca...> ----------------------------------------------------------------------- Summary of changes: testcases/kernel/mem/lib/mem.c | 18 ++++++++++-------- 1 files changed, 10 insertions(+), 8 deletions(-) diff --git a/testcases/kernel/mem/lib/mem.c b/testcases/kernel/mem/lib/mem.c index 76ddb94..e25b5be 100644 --- a/testcases/kernel/mem/lib/mem.c +++ b/testcases/kernel/mem/lib/mem.c @@ -744,17 +744,18 @@ void set_sys_tune(char *sys_file, long tune, int check) { int fd; long val; - char buf[BUFSIZ]; + char buf[BUFSIZ], path[BUFSIZ]; tst_resm(TINFO, "set %s to %ld", sys_file, tune); - fd = open(sys_file, O_WRONLY); + snprintf(path, BUFSIZ, "%s%s", PATH_SYSVM, sys_file); + fd = open(path, O_WRONLY); if (fd == -1) - tst_brkm(TBROK|TERRNO, cleanup, "open '%s'", sys_file); + tst_brkm(TBROK|TERRNO, cleanup, "open %s", sys_file); if (snprintf(buf, BUFSIZ, "%ld", tune) < 0) tst_brkm(TBROK|TERRNO, cleanup, "snprintf"); if (write(fd, buf, strlen(buf)) != strlen(buf)) - tst_brkm(TBROK|TERRNO, cleanup, "write '%s'", sys_file); + tst_brkm(TBROK|TERRNO, cleanup, "write %s", sys_file); close(fd); if (check) { @@ -769,13 +770,14 @@ long get_sys_tune(char *sys_file) { int fd; long tune; - char buf[BUFSIZ], *endptr; + char buf[BUFSIZ], path[BUFSIZ], *endptr; - fd = open(sys_file, O_RDONLY); + snprintf(path, BUFSIZ, "%s%s", PATH_SYSVM, sys_file); + fd = open(path, O_RDONLY); if (fd == -1) - tst_brkm(TBROK|TERRNO, cleanup, "open '%s'", sys_file); + tst_brkm(TBROK|TERRNO, cleanup, "open %s", sys_file); if (read(fd, buf, BUFSIZ) < 0) - tst_brkm(TBROK|TERRNO, cleanup, "read '%s'", sys_file); + tst_brkm(TBROK|TERRNO, cleanup, "read %s", sys_file); close(fd); tune = strtol(buf, &endptr, 10); hooks/post-receive -- ltp |