On Tue, 2014-04-29 at 18:31 +0200, [email protected] wrote:
> Hi!
> >  static struct test_case_t {
> >     int *fd;
> > -   void *buf;
> > +   void **buf;
> > +   size_t count;
> >     int exp_error;
> >  } TC[] = {
> > -   {&badfd, buf, EBADF},
> > -   {&fd2, buf, EISDIR},
> > -   {&fd3, (void *)-1, EFAULT},
> > +   {&badfd, (void **)&buf, 1, EBADF},
> > +   {&fd2, (void **)&buf, 1, EISDIR},
> > +   {&fd3, &outside_buf, 1, EFAULT},
> > +   {&fd4, &addr4, 4096, EINVAL},
> > +   {&fd4, &addr5, 1, EINVAL},
> >  };
> >  
> >  int TST_TOTAL = ARRAY_SIZE(TC);
> > @@ -89,6 +107,11 @@ int main(int ac, char **av)
> >  
> >  static void setup(void)
> >  {
> > +   if ((tst_kvercmp(2, 4, 10)) < 0)
> > +           tst_brkm(TCONF, NULL, "This test needs kernel 2.4.10 or newer");
> 
> Linux 2.4.10 is from 2001 I would say that it's old enough so we can
> expect that O_DIRECT is generally available.
> 

OK. I will remove tst_kvercmp.

> > +   tst_require_root(NULL);
> 
> Does O_DIRECT require root?
> (I haven't found anything in read man page that would suggests so)
> 

In fedora20, /tmp is tmpfs.
This test will fail if open a file with O_DIRECT in /tmp, like:
read02      1  TBROK  :  open failed at read02.c:147: errno=EINVAL(22):
Invalid argument
So I test it in /root.

> >     tst_sig(NOFORK, DEF_HANDLER, cleanup);
> >  
> >     TEST_PAUSE;
> > @@ -100,11 +123,19 @@ static void setup(void)
> >     SAFE_FILE_PRINTF(cleanup, TEST_FILE, "A");
> >  
> >     fd3 = SAFE_OPEN(cleanup, TEST_FILE, O_RDWR | O_CREAT, 0666);
> > +
> > +   temp = SAFE_MALLOC(cleanup, 4096*10);
> > +
> > +   addr4 = (char *)(((long)buf & (~4095)) + 1);
> > +   addr5 = (char *)((long)buf & (~4095));
> 
> You can allocate aligned buffer with memalign() instead.
> 

OK. I will use it.

> > +   SAFE_FILE_PRINTF(cleanup, TEST_FILE4, "A");
> > +   fd4 = SAFE_OPEN(cleanup, TEST_FILE4, O_RDWR | O_DIRECT, 0777);
> >  }
> >  
> >  static void read_verify(const struct test_case_t *test)
> >  {
> > -   TEST(read(*test->fd, test->buf, 1));
> > +   TEST(read(*test->fd, *test->buf, test->count));
> >  
> >     if (TEST_RETURN != -1) {
> >             tst_resm(TFAIL, "call succeeded unexpectedly");
> > @@ -127,6 +158,14 @@ static void cleanup(void)
> >  {
> >     TEST_CLEANUP;
> >  
> > +   free(temp);
> > +
> > +   if (fd4 > 0)
> > +           close(fd4);
> > +
> > +   if (unlink(TEST_FILE4) < 0)
> > +           tst_resm(TWARN | TERRNO, "unlink(\"%s\") failed", TEST_FILE4);
> 
> There is no need to unlink files if you call tst_rmdir(). You only need
> to close filedescriptors.
> 

TEST_FILE4 is not in /tmp.

Best regards,
Zeng

> >     if (fd3 > 0)
> >             close(fd3);
> >  
> 



------------------------------------------------------------------------------
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
&#149; 3 signs your SCM is hindering your productivity
&#149; Requirements for releasing software faster
&#149; Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to