From: Cyril Hrubis <chrubis@suse.cz>
To: tangchen <tangchen@cn.fujitsu.com>
Cc: "ltp-list@lists.sourceforge.net" <ltp-list@lists.sourceforge.net>
Subject: Re: [LTP] [PATCH 3/6] hugemmap01.c
Date: Fri, 2 Sep 2011 14:43:52 +0200 [thread overview]
Message-ID: <20110902124352.GA14558@saboteur.suse.cz> (raw)
In-Reply-To: <4E4A2359.2040602@cn.fujitsu.com>
Hi!
> #include "test.h"
> #include "usctest.h"
> #include "system_specific_hugepages_info.h"
> +#include "libmnt.h"
>
> #define BUFFER_SIZE 256
>
> -char* TEMPFILE="mmapfile";
> +char TEMPFILE[MAXPATHLEN];
>
> char *TCID="hugemmap01"; /* Test program identifier. */
> int TST_TOTAL=1; /* Total number of test cases. */
> long *addr; /* addr of memory mapped region */
> int fildes; /* file descriptor for tempfile */
> -char *Hopt; /* location of hugetlbfs */
> +int hugepagesmapped=0; /* Amount of huge pages mapped after testing */
> 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 */
> +char *mount_point=NULL;
>
> -void setup(); /* Main setup function of test */
> -void cleanup(); /* cleanup function for the test */
> -
> -void help()
> -{
> - printf(" -H /.. Location of hugetlbfs, i.e. -H /var/hugetlbfs \n");
> -}
> +void setup(void); /* Main setup function of test */
> +void cleanup(void); /* cleanup function for the test */
>
> int
> main(int ac, char **av)
> {
> int lc; /* loop counter */
> - char *msg; /* message returned from parse_opts */
> - int Hflag=0; /* binary flag: opt or not */
> int page_sz=0;
>
> - option_t options[] = {
> - { "H:", &Hflag, &Hopt }, /* Required for location of hugetlbfs */
> - { NULL, NULL, NULL } /* NULL required to end array */
> - };
> -
> - /* Parse standard options given to run the test. */
> - msg = parse_opts(ac, av, options, &help);
> - if (msg != (char *) NULL) {
> - tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s, use -help", msg);
> - tst_exit();
> - }
The parse_opts() should stay here but with NULL parameters there are
some default options and it makes the test bail out on invalid options
passed.
> - if (Hflag == 0) {
> - tst_brkm(TBROK, NULL, "-H option is REQUIRED for this test, use -h for options help");
> - tst_exit();
> - }
> -
> setup();
>
> for (lc = 0; TEST_LOOPING(lc); lc++) {
> @@ -189,18 +166,22 @@ main(int ac, char **av)
> * Write some known data into file and get the size of the file.
> */
> void
> -setup()
> +setup(void)
> {
> - char mypid[40];
> -
> - sprintf(mypid,"/%d",getpid());
> - TEMPFILE=strcat(mypid,TEMPFILE);
> - TEMPFILE=strcat(Hopt,TEMPFILE);
> + tst_require_root(NULL);
>
> tst_sig(FORK, DEF_HANDLER, cleanup);
>
> TEST_PAUSE;
>
> + tst_tmpdir();
> + mount_point = get_tst_tmpdir();
> +
> + mount_hugetlbfs(mount_point);
> + hugepage_alloc(1024);
> +
> + snprintf(TEMPFILE, sizeof(TEMPFILE), "%s/mmapfile%d",
> + mount_point, getpid());
> }
>
> /*
> @@ -209,7 +190,7 @@ setup()
> * Remove the temporary directory created.
> */
> void
> -cleanup()
> +cleanup(void)
> {
> /*
> * print timing stats if that option was specified.
> @@ -218,4 +199,6 @@ cleanup()
>
> unlink(TEMPFILE);
>
> + umount_hugetlbfs(mount_point);
> + tst_rmdir();
> }
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
Special Offer -- Download ArcSight Logger for FREE!
Finally, a world-class log management solution at an even better
price-free! And you'll get a free "Love Thy Logs" t-shirt when you
download Logger. Secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsisghtdev2dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next parent reply other threads:[~2011-09-02 12:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <4E377560.7060600@cn.fujitsu.com>
[not found] ` <4E4A2359.2040602@cn.fujitsu.com>
2011-09-02 12:43 ` Cyril Hrubis [this message]
2011-09-02 12:47 ` [LTP] [PATCH 3/6] hugemmap01.c Cyril Hrubis
[not found] ` <4E66D3C5.80001@cn.fujitsu.com>
[not found] ` <4E66D492.1030907@cn.fujitsu.com>
2011-09-08 11:59 ` Cyril Hrubis
2011-11-22 9:39 ` [LTP] [PATCH 0/6] Automatically mount hugetlbfs for hugemmap tests tangchen
2011-11-22 10:11 ` Garrett Cooper
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110902124352.GA14558@saboteur.suse.cz \
--to=chrubis@suse.cz \
--cc=ltp-list@lists.sourceforge.net \
--cc=tangchen@cn.fujitsu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.