Hej alla
I ltp -
POSIX test, det är ett fall i open_posix_testsuite \ överrensstämmelse \ Interfaces \ timer_gettime \ speculative/6-1.c
Citat:
# include <time.h>
# include <stdio.h>
# include <errno. h>
/ / # include "posixtest.h"
# define BOGUSTID 9.999
int viktigaste (int argc, char * argv [])
(
timer_t tid;
struct itimerspec dess;
tid \u003d (timer_t) BOGUSTID;
if (timer_gettime (tid, och dess) \u003d\u003d -1) (
if (EINVAL \u003d\u003d errno) (
printf ( "FCN returneras -1 och errno\u003d\u003d EINVAL \ n ");
/ / return PTS_PASS;
) Else (
printf ( "FCN returneras -1 men errno! \u003d EINVAL \ n ");
printf ( "Test tappat \ n");
/ / return PTS_FAIL;
)
)
printf ( "FCN inte återvända -1 \ n");
/ / return PTS_PASS;
)
|
Jag kör ovanstående kod, det kommer har ett segment fel, om jag ändrar det till nedan, fungerar det bra
Citat:
# include <time.h>
# include <stdio.h>
# include <errno. h>
/ / # include "posixtest.h"
# define BOGUSTID 9.999
int viktigaste (int argc, char * argv [])
(
timer_t tid;
struct itimerspec dess;
int Tvål \u003d BOGUSTID;
printf ( "% d \ n", Tvål);
tid \u003d (timer_t) &tval;
printf ( "% d \ n", tid);
if (timer_gettime (tid, och dess) \u003d\u003d -1) (
if (EINVAL \u003d\u003d errno) (
printf ( "FCN returneras -1 och errno\u003d\u003d EINVAL \ n ");
/ / return PTS_PASS;
) Else (
printf ( "FCN returneras -1 men errno! \u003d EINVAL \ n ");
printf ( "Test tappat \ n");
/ / return PTS_FAIL;
)
)
printf ( "FCN inte återvända -1 \ n");
/ / Return PTS_PASS;
)
|
Vem som helst kan berätta för mig varför?