Hi, Any comment of this patch, if no, would you push it?
On 03/24/2011 06:21 PM, tangchen wrote: > Hi, > > hugemmap test could fail because I didn't mount hugetlbfs by myself. And > I need to umount it after test. > > In my opinion, > firstly, mounting hugetlbfs on /tmp is not a good idea, because lots of > programs could use /tmp for other purpose. This could cause other tests > fail; > secondly, mounting hugetlbfs could be done automatically. > This patch creates a directory /huge, automatically mounts hugetlbfs on > /huge before test starts, and umounts it when the test is over. > > Signed-off-by: tangchen <[email protected]> > --- > runtest/hugetlb | 2 +- > testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c | 38 > +++++++++++++++++++- > 2 files changed, 38 insertions(+), 2 deletions(-) > > diff --git a/runtest/hugetlb b/runtest/hugetlb > index 1347f32..1490bda 100644 > --- a/runtest/hugetlb > +++ b/runtest/hugetlb > @@ -1,4 +1,4 @@ > -hugemmap01 hugemmap01 -H/tmp > +hugemmap01 hugemmap01 -H/huge > hugemmap02 hugemmap02 -H/tmp -c10 > hugemmap03 hugemmap03 -H/tmp -I2 -c10 > hugemmap04 hugemmap04 -H/tmp > diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c > b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c > index a9b8a36..0ac411d 100644 > --- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c > +++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap01.c > @@ -69,6 +69,7 @@ > #include <sys/stat.h> > #include <sys/mman.h> > #include <sys/types.h> > +#include <sys/mount.h> > > #include "test.h" > #include "usctest.h" > @@ -85,6 +86,9 @@ char *Hopt; /* location of > hugetlbfs */ > int beforetest=0; /* Amount of free huge pages before testing */ > int aftertest=0; /* Amount of free huge pages after testing */ > int hugepagesmapped=0; /* Amount of huge pages mapped after > testing */ > +FILE *nr_hugepages_file = NULL; /* Used for allocate enough hugepages > for test. */ > +char *mount_point = NULL; /* The location where we mount hugetlbfs. */ > +int mkdir_err = 0; /* Used to judge if we need to remove the > mount point. */ > > void setup(); /* Main setup function of test */ > int getfreehugepages(); /* Reads free huge pages */ > @@ -121,6 +125,7 @@ main(int ac, char **av) > tst_exit(); > } > > + mount_point = (char *)malloc(sizeof(char) * 50); > setup(); > > for (lc = 0; TEST_LOOPING(lc); lc++) { > @@ -195,6 +200,33 @@ setup() > { > char mypid[40]; > > + mount_point = strcpy(mount_point, Hopt); > + > + tst_require_root(tst_exit); > + > + int ret = mkdir(mount_point, 0755); > + mkdir_err = errno; > + if (ret < 0 && mkdir_err != EEXIST) { > + tst_brkm(TBROK, NULL, "mkdir() Failed on %s, errno=%d : %s", > + mount_point, errno, strerror(errno)); > + } > + > + if (mount("none", mount_point, "hugetlbfs", 0, NULL) < 0) { > + tst_brkm(TBROK, NULL, "mount() Failed on %s, errno=%d : %s", > + mount_point, errno, strerror(errno)); > + } > + > + nr_hugepages_file = fopen("/proc/sys/vm/nr_hugepages", "w+"); > + if (nr_hugepages_file == NULL) { > + tst_brkm(TBROK, NULL, "fopen() Failed on > /proc/sys/vm/nr_hugepages, " > + "errno=%d : %s", errno, strerror(errno)); > + } > + if (fprintf(nr_hugepages_file, "%d", 1024) < 0) { > + tst_brkm(TBROK, NULL, "fprintf() Failed on > /proc/sys/vm/nr_hugepages, " > + "errno=%d : %s", errno, strerror(errno)); > + } > + fclose(nr_hugepages_file); > + > sprintf(mypid,"/%d",getpid()); > TEMPFILE=strcat(mypid,TEMPFILE); > TEMPFILE=strcat(Hopt,TEMPFILE); > @@ -275,5 +307,9 @@ cleanup() > TEST_CLEANUP; > > unlink(TEMPFILE); > + umount(mount_point); > > -} > \ No newline at end of file > + if (mkdir_err != EEXIST) { > + remove(mount_point); > + } > +} -- Best Regards, Tang chen ------------------------------------------------------------------------------ Xperia(TM) PLAY It's a major breakthrough. An authentic gaming smartphone on the nation's most reliable network. And it wants your games. http://p.sf.net/sfu/verizon-sfdev _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
