本文整理汇总了C++中TEST函数的典型用法代码示例。如果您正苦于以下问题:C++ TEST函数的具体用法?C++ TEST怎么用?C++ TEST使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TEST函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int ac, char **av)
{
int lc; /* loop counter */
char *msg; /* message returned from parse_opts */
int incr; /* increment */
long nbrkpt; /* new brk point value */
long cur_brk_val; /* current size returned by sbrk */
long aft_brk_val; /* current size returned by sbrk */
if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
setup();
/*
* Attempt to control how fast we get to test max size.
* Every MAX_SIZE_LC'th lc will be fastest test will reach max size.
*/
incr = (Max_brk_byte_size - Beg_brk_val) / (MAX_SIZE_LC / 2);
if ((incr * 2) < 4096) /* make sure that process will grow */
incr += 4096 / 2;
for (lc = 0; TEST_LOOPING(lc); lc++) {
Tst_count = 0;
/*
* Determine new value to give brk
* Every even lc value, grow by 2 incr and
* every odd lc value, strink by one incr.
* If lc is equal to 3, no change, special case.
*/
cur_brk_val = (long)sbrk(0);
if (lc == 3) {
nbrkpt = cur_brk_val; /* no change, special one time case */
} else if ((lc % 2) == 0) {
/*
* grow
*/
nbrkpt = cur_brk_val + (2 * incr);
if (nbrkpt > Max_brk_byte_size)
nbrkpt = Beg_brk_val; /* start over */
} else {
/*
* shrink
*/
nbrkpt = cur_brk_val - incr;
}
/****
printf("cur_brk_val = %d, nbrkpt = %d, incr = %d, lc = %d\n",
cur_brk_val, nbrkpt, incr, lc);
****/
/*
* Call brk(2)
*/
TEST(brk((char *)nbrkpt));
/* check return code */
if (TEST_RETURN == -1) {
aft_brk_val = (long)sbrk(0);
tst_resm(TFAIL|TTERRNO,
"brk(%ld) failed (size before %ld, after %ld)",
nbrkpt, cur_brk_val, aft_brk_val);
} else {
if (STD_FUNCTIONAL_TEST) {
aft_brk_val = (long)sbrk(0);
if (aft_brk_val == nbrkpt) {
tst_resm(TPASS,
"brk(%ld) returned %ld, new size verified by sbrk",
nbrkpt, TEST_RETURN);
} else {
tst_resm(TFAIL,
"brk(%ld) returned %ld, sbrk before %ld, after %ld",
nbrkpt, TEST_RETURN,
cur_brk_val, aft_brk_val);
}
}
}
}
cleanup();
tst_exit();
}
示例2: TestStoreRoot
static void TestStoreRoot() {
{
CBook book;
CHeightInfoX hix(2, 4, false, 60);
CQPosition pos("---------------------------O*------*O---------------------------", true);
const CValue value=32;
const CValue cutoff=-100;
book.StoreRoot(pos.BitBoard(), hix, value, cutoff);
TEST(book.Size()==1);
const CBookData* bd=book.FindData(pos.BitBoard());
TEST(bd!=NULL);
TEST(bd->IsBranch());
TEST(!bd->IsUleaf());
TEST(!bd->IsLeaf());
TEST(!bd->IsProven());
TEST(bd->Hi()==hix);
// don't test values as they won't be assigned.
}
{
// now a solved root node
CBook book;
CQPosition pos("OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO*OOOOOO-----------------", true);
const CValue value=-64*kStoneValue;
CHeightInfoX hix(pos.NEmpty()-hSolverStart, 0, false, pos.NEmpty());
book.StoreRoot(pos.BitBoard(), hix, value, -100);
TEST(book.Size()==1);
const CBookData* bd=book.FindData(pos.BitBoard());
TEST(bd!=NULL);
TEST(bd->IsLeaf());
TEST(bd->IsProven());
TEST(!bd->IsUleaf());
TEST(!bd->IsBranch());
TEST(bd->Hi()==hix);
TEST(bd->Values().vMover==value+book.Boni().whiteBonus);
TEST(bd->Values().vOpponent==value+book.Boni().whiteBonus);
TEST(bd->Values().vHeuristic==value);
}
}
示例3: TestFindQuestionableNode
void TestFindQuestionableNode() {
COsGame game;
game.Initialize("8");
CQPosition initialPos(game, 0);
CQPosition questionablePosition;
CBook book;
bool drawToMover;
// The position is not in book. FindQuestionableNode should return NULL.
bool isQuestionable = book.FindQuestionableNode(questionablePosition, drawToMover, initialPos, drawCutoff, deviationCutoff);
TEST(!isQuestionable);
// add the initial position to the book. FindQuestionableNode should return the initial position.
const CBitBoard initialBitBoard(initialPos.BitBoard());
CMinimalReflection mr(initialBitBoard);
CHeightInfoX heightInfoX(2, 4, false, initialBitBoard.NEmpty());
book.StoreLeaf(CMinimalReflection(initialBitBoard), heightInfoX, 0);
isQuestionable = book.FindQuestionableNode(questionablePosition, drawToMover, initialPos, drawCutoff, deviationCutoff);
TEST(isQuestionable);
TEST(questionablePosition==initialPos);
// add the initial position to the book with a deviation of the deviation cutoff
// Since this is bigger than the threshold for deviations, we won't count it.
book.StoreLeaf(CMinimalReflection(initialBitBoard), heightInfoX, deviationCutoff);
isQuestionable = book.FindQuestionableNode(questionablePosition, drawToMover, initialPos, drawCutoff, deviationCutoff);
TEST(!isQuestionable);
// but if it's one less than the deviation cutoff, it's questionable
book.StoreLeaf(CMinimalReflection(initialBitBoard), heightInfoX, deviationCutoff-1);
isQuestionable = book.FindQuestionableNode(questionablePosition, drawToMover, initialPos, drawCutoff, deviationCutoff);
TEST(isQuestionable);
TEST(questionablePosition==initialPos);
// Also if it's negative... at the deviation cutoff is ok, one more is questionable
book.StoreLeaf(CMinimalReflection(initialBitBoard), heightInfoX, -deviationCutoff);
isQuestionable = book.FindQuestionableNode(questionablePosition, drawToMover, initialPos, drawCutoff, deviationCutoff);
TEST(!isQuestionable);
book.StoreLeaf(CMinimalReflection(initialBitBoard), heightInfoX, 1-deviationCutoff);
isQuestionable = book.FindQuestionableNode(questionablePosition, drawToMover, initialPos, drawCutoff, deviationCutoff);
TEST(isQuestionable);
TEST(questionablePosition==initialPos);
// This node is a draw, at +3/-3.. so it's ok
const CBookData* bookData = book.FindData(initialBitBoard);
// casting to remove const is a really bad idea... but no other easy way to test
CBookValue& bookValue = (CBookValue&)(bookData->Values());
bookValue.vHeuristic = 0;
bookValue.vMover = drawCutoff;
bookValue.vOpponent = - drawCutoff;
isQuestionable = book.FindQuestionableNode(questionablePosition, drawToMover, initialPos, drawCutoff, deviationCutoff);
TEST(!isQuestionable);
TEST(questionablePosition==initialPos);
CQPosition nextPos(initialPos);
nextPos.MakeMove(CMove("F5"));
const CBitBoard f5 = nextPos.BitBoard();
nextPos.MakeMove(CMove("D6"));
const CBitBoard f5d6 = nextPos.BitBoard();
nextPos = initialPos;
nextPos.MakeMove(CMove("F5"));
nextPos.MakeMove(CMove("F6"));
const CBitBoard f5f6 = nextPos.BitBoard();
// Now we have a questionable position, but it's not at the initial node
// tree is:
// f5 d6 : proven draw
// f5 f6 : deviation with value drawValue
book.StoreRoot(initialBitBoard, heightInfoX, 0, -16400);
book.StoreRoot(f5, heightInfoX, 0, -16400);
CHeightInfoX hixSolved = CHeightInfoX(f5f6.NEmpty(), 0, false, f5f6.NEmpty());
book.StoreLeaf(f5f6, hixSolved, 0);
book.StoreLeaf(f5d6, heightInfoX, drawCutoff);
book.NegamaxAll();
isQuestionable = book.FindQuestionableNode(questionablePosition, drawToMover, initialPos, drawCutoff, deviationCutoff);
TEST(isQuestionable);
TEST(CMinimalReflection(questionablePosition.BitBoard())==CMinimalReflection(f5d6));
// This position has a questionable node, but it's not on the draw tree so it's not returned
CBook book2;
book2.StoreRoot(initialBitBoard, heightInfoX, -deviationCutoff, -16400);
book2.StoreRoot(f5, heightInfoX, deviationCutoff, -16400);
book2.StoreLeaf(f5f6, heightInfoX, -deviationCutoff);
book2.StoreLeaf(f5d6, heightInfoX, 0);
book2.NegamaxAll();
isQuestionable = book2.FindQuestionableNode(questionablePosition, drawToMover, initialPos, drawCutoff, deviationCutoff);
TEST(!isQuestionable);
}
示例4: TEST
void TestThreading::runTests(IGameDef *)
{
TEST(testAtomicSemaphoreThread);
}
示例5: main
int
main(int ac, char **av)
{
int lc; /* loop counter */
char *msg; /* message returned from parse_opts */
pid_t cpid; /* process id of the child process */
int exit_status; /* exit status of child process */
sigset_t PendSig; /* variable to hold pending signal */
/* Parse standard options given to run the test. */
msg = parse_opts(ac, av, (option_t *) NULL, NULL);
if (msg != (char *) NULL) {
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
tst_exit();
}
/* Perform global setup for test */
setup();
/* set the expected errnos... */
TEST_EXP_ENOS(exp_enos);
/* Check looping state if -i option given */
for (lc = 0; TEST_LOOPING(lc); lc++) {
/* Reset Tst_count in case we are looping. */
Tst_count=0;
/*
* Call vfork(2) to create a child process without
* fully copying the address space of parent.
*/
TEST(vfork());
/* check return code of vfork() */
if ((cpid = TEST_RETURN) == -1) {
TEST_ERROR_LOG(TEST_ERRNO);
tst_resm(TFAIL, "vfork() Failed, errno=%d : %s",
TEST_ERRNO, strerror(TEST_ERRNO));
} else if (cpid == 0) { /* Child process */
/*
* Perform functional verification if test
* executed without (-f) option.
*/
if (STD_FUNCTIONAL_TEST) {
/*
* Check whether the pending signal SIGUSR1
* in the parent is also pending in the child
* process by storing it in a variable.
*/
if (sigpending(&PendSig) == -1) {
tst_resm(TFAIL, "sigpending function "
"failed in child");
_exit(1);
}
/* Check if SIGUSR1 is pending in child */
if (sigismember(&PendSig, SIGUSR1) != 0) {
tst_resm(TFAIL, "SIGUSR1 also pending "
"in child process");
_exit(1);
}
/*
* Exit with normal exit code if everything
* fine
*/
_exit(0);
}
} else { /* parent process */
/*
* Let the parent process wait till child completes
* its execution.
*/
wait(&exit_status);
/* Check for the exit status of child process */
if (WEXITSTATUS(exit_status) == 0) {
tst_resm(TPASS, "Call to vfork() "
"successful");
} else if (WEXITSTATUS(exit_status) == 1) {
tst_resm(TFAIL, \
"Child process exited abnormally");
}
}
Tst_count++; /* incr. TEST_LOOP counter */
} /* End for TEST_LOOPING */
/* Call cleanup() to undo setup done for the test. */
cleanup();
return 0;
} /* End main */
示例6: do_test
static int
do_test (void)
{
#if LDBL_MANT_DIG >= 106
volatile union { long double l; long long x[2]; } u, v;
char buf[64];
#endif
int result = 0;
#if LDBL_MANT_DIG == 106 || LDBL_MANT_DIG == 113
# define COMPARE_LDBL(u, v) \
((u).l == (v).l && (u).x[0] == (v).x[0] && (u).x[1] == (v).x[1])
#else
# define COMPARE_LDBL(u, v) ((u).l == (v).l)
#endif
#define TEST(val) \
do \
{ \
u.l = (val); \
snprintf (buf, sizeof buf, "%.30LgL", u.l); \
if (strcmp (buf, #val) != 0) \
{ \
printf ("Error on line %d: %s != %s\n", __LINE__, buf, #val); \
result = 1; \
} \
if (sscanf (#val, "%Lg", &v.l) != 1 || !COMPARE_LDBL (u, v)) \
{ \
printf ("Error sscanf on line %d: %.30Lg != %.30Lg\n", __LINE__, \
u.l, v.l); \
result = 1; \
} \
/* printf ("%s %Lg %016Lx %016Lx\n", #val, u.l, u.x[0], u.x[1]); */ \
} \
while (0)
#if LDBL_MANT_DIG >= 106
# if LDBL_MANT_DIG == 106
TEST (2.22507385850719347803989925739e-308L);
TEST (2.22507385850719397210554509863e-308L);
TEST (2.22507385850720088902458687609e-308L);
# endif
TEST (2.22507385850720138309023271733e-308L);
TEST (2.22507385850720187715587855858e-308L);
TEST (2.2250738585074419930597574044e-308L);
TEST (4.45014771701440227211481959342e-308L);
TEST (4.45014771701440276618046543466e-308L);
TEST (4.45014771701440375431175711716e-308L);
TEST (4.45014771701440474244304879965e-308L);
TEST (7.12023634722304600689881138745e-307L);
TEST (1.13923781555569064960474854133e-305L);
TEST (1.13777777777777776389998996996L);
TEST (1.13777777777777765287768750745L);
TEST (20988295479420645138.2044444444L);
TEST (20988295479420643090.2044444444L);
TEST (2.14668699894294423266045294316e-292L);
# if LDBL_MANT_DIG == 106
TEST (-2.35993711055432139266626434123e-292L);
TEST (6.26323524637968345414769634658e-302L);
TEST (1.49327164802066885331814201989e-308L);
TEST (3.71834550652787023640837473722e-308L);
TEST (9.51896449671134907001349268087e-306L);
# endif
#endif
return result;
}
示例7: main
int main()
{
//fast access
using program_language = l_language::l_vm;
using compiler_flags = l_language::l_vm::compiler_flags;
//source file
std::string i_source = "scripts/function.ll";
int f_compier_flags = compiler_flags::EXECUTE;
//compiler object
program_language it_compiler;
//add libs
it_compiler.add_lib(l_language::l_base_lib);
it_compiler.add_lib("io", l_language::l_io_lib);
it_compiler.add_lib("os", l_language::l_os_lib);
//read code // "source.it"
std::ifstream source_file(i_source);
std::string source((std::istreambuf_iterator<char>(source_file)),
(std::istreambuf_iterator<char>()));
//compile
program_language::compiler_ouput compiler_ouput;
compiler_ouput = it_compiler.compile(source,f_compier_flags);
//ouput:
if(compiler_ouput.m_type & program_language::ERRORS)
{
std::cout << compiler_ouput.m_errors;
return -1;
}
//tests
TEST("pow2", // test name
pow2, // function
36.0f, // return
6.0f // args
);
TEST("diff", // test name
diff, // function
1.0f, // return
2.0f, 1.0f // args
);
TEST("fib", // test name
fib, // function
89.0f, // return
10.0f // args
);
TEST("super", // test name
super_test, // function
5.0f, // return
0.0f // args
);
TEST("for of", // test name
for_of_test, // function
15.0f, // return
0.0f // args
);
TEST("for in", // test name
for_in_test, // function
10.0f, // return
0.0f // args
);
TEST_TYPE_OF("is int", // test name
int_test, // function
INT, // return type
0 // args
);
TEST_TYPE_OF("is float", // test name
float_test, // function
FLOAT, // return type
0 // args
);
TEST_TYPE_OF("is string", // test name
string_test, // function
STRING, // return type
0 // args
);
std::vector<l_language::l_variable> array_test_values =
{
1.2f,
3,
l_language::l_string::const_new(it_compiler.get_gc(), "hello"),
l_language::l_string::const_new(it_compiler.get_gc(), "l"),
l_language::l_string::const_new(it_compiler.get_gc(), "language")
};
TEST_ARRAY("generic test array", // test name
array_test, // function
array_test_values, // return
0 // args
);
//1-100
int range_values = rand() % 100 + 1;
//.........这里部分代码省略.........
示例8: main
int main(int ac, char **av)
{
int lc, i; /* loop counter */
char *msg; /* message returned from parse_opts */
/* parse standard options */
if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
setup();
for (lc = 0; TEST_LOOPING(lc); lc++) {
Tst_count = 0;
for (i = 0; i < TST_TOTAL; i++) {
if (testcase[i].setupfunc &&
testcase[i].setupfunc() == -1) {
tst_resm(TWARN, "Failed to setup test %d."
" Skipping test", i);
continue;
} else {
TEST(syscall(__NR_swapoff, testcase[i].path));
}
if (testcase[i].cleanfunc &&
testcase[i].cleanfunc() == -1) {
tst_brkm(TBROK, cleanup, "cleanup failed,"
" quitting the test");
}
/* check return code */
if ((TEST_RETURN == -1) && (TEST_ERRNO == testcase[i].
exp_errno)) {
tst_resm(TPASS, "swapoff(2) expected failure;"
" Got errno - %s : %s",
testcase[i].exp_errval,
testcase[i].err_desc);
} else {
tst_resm(TFAIL, "swapoff(2) failed to produce"
" expected error; %d, errno"
": %s and got %d",
testcase[i].exp_errno,
testcase[i].exp_errval, TEST_ERRNO);
if ((TEST_RETURN == 0) && (i == 2)) {
if (syscall(__NR_swapon, "./swapfile01", 0) != 0) {
tst_brkm(TBROK, cleanup,
" Failed to turn on"
" swap file");
}
}
}
TEST_ERROR_LOG(TEST_ERRNO);
} /*End of TEST LOOPS */
}
/*Clean up and exit */
cleanup();
tst_exit();
} /*End of main */
示例9: do_master_child
/*
* do_master_child()
*/
void do_master_child()
{
int lc;
int pid;
int status;
for (lc = 0; TEST_LOOPING(lc); lc++) {
int tst_fd;
/* Reset tst_count in case we are looping */
tst_count = 0;
if (setreuid(0, ltpuser->pw_uid) == -1) {
perror("setfsuid failed");
exit(1);
}
/* Test 1: Check the process with new uid cannot open the file
* with RDWR permissions.
*/
TEST(tst_fd = open(testfile, O_RDWR));
if (TEST_RETURN != -1) {
printf("open succeeded unexpectedly\n");
close(tst_fd);
exit(1);
}
if (TEST_ERRNO == EACCES) {
printf("open failed with EACCES as expected\n");
} else {
perror("open failed unexpectedly");
exit(1);
}
/* Test 2: Check a son process cannot open the file
* with RDWR permissions.
*/
pid = FORK_OR_VFORK();
if (pid < 0)
tst_brkm(TBROK, cleanup, "Fork failed");
if (pid == 0) {
int tst_fd2;
/* Test to open the file in son process */
TEST(tst_fd2 = open(testfile, O_RDWR));
if (TEST_RETURN != -1) {
printf("call succeeded unexpectedly\n");
close(tst_fd2);
exit(1);
}
TEST_ERROR_LOG(TEST_ERRNO);
if (TEST_ERRNO == EACCES) {
printf("open failed with EACCES as expected\n");
exit(0);
} else {
printf("open failed unexpectedly\n");
exit(1);
}
} else {
/* Wait for son completion */
if (waitpid(pid, &status, 0) == -1) {
perror("waitpid failed");
exit(1);
}
if (!WIFEXITED(status) || (WEXITSTATUS(status) != 0))
exit(WEXITSTATUS(status));
}
/* Test 3: Fallback to initial uid and check we can again open
* the file with RDWR permissions.
*/
tst_count++;
if (setreuid(0, 0) == -1) {
perror("setfsuid failed");
exit(1);
}
TEST(tst_fd = open(testfile, O_RDWR));
if (TEST_RETURN == -1) {
perror("open failed unexpectedly");
exit(1);
} else {
printf("open call succeeded\n");
close(tst_fd);
}
}
exit(0);
}
示例10: TestEventViewWithFilterL
/**
@SYMTestCaseID SYSLIB-LOGENG-CT-0129
@SYMTestCaseDesc Test that a view only contains events that are suitable for a clients cabability
@SYMTestPriority High
@SYMTestActions See comments in the trest code below for further info.
@SYMTestExpectedResults Should always succeed
@SYMREQ REQ3431
*/
LOCAL_C void TestEventViewWithFilterL(CLogClient& aClient)
{
// TestUtils::AddTestEventsL() --> should be called before this function.
// It deletes the database, then...
// adds 8 events - 2 are visible to clients with no capabilities
// and 6 are of type KLogCallEventTypeUid, which is protected.
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0129 "));
CTestActive* active = new(ELeave)CTestActive;
CleanupStack::PushL(active);
CLogFilterList* list = new(ELeave)CLogFilterList;
CleanupStack::PushL(list);
CLogViewEvent* view = CLogViewEvent::NewL(aClient);
CleanupStack::PushL(view);
CLogFilter* filter = CLogFilter::NewL();
CleanupStack::PushL(filter);
TLogString direction;
aClient.GetString(direction, R_LOG_DIR_IN);
// Test 1.
// Of the 8 new events, 2 have KTestContact1 as the contact field
// One of them is a secure type and the other isn't.
// So, if running at hi capability, expect 2 events, else 1
TInt expectedEventCount = (TheHiCapability) ? 2 : 1;
filter->SetContact(KTestContact1);
list->AppendL(filter);
active->StartL();
TEST(view->SetFilterL(*list, active->iStatus));
CActiveScheduler::Start();
TEST(view->CountL() == expectedEventCount);
// Test 2.
// Of the 8 new events, 6 have KTestContact2 as the contact field
// One of them is a secure type and the other isn't.
// The filters will be combined in the query, so expect
// 8 events if running at hi capability, else 2
expectedEventCount = (TheHiCapability) ? 8 : 2;
CleanupStack::Pop(); // filter
filter = CLogFilter::NewL();
CleanupStack::PushL(filter);
filter->SetContact(KTestContact2);
list->AppendL(filter);
active->StartL();
TEST(view->SetFilterL(*list, active->iStatus));
CActiveScheduler::Start();
TEST(view->CountL() == expectedEventCount);
// Test 3.
// Of the 8 new events, 7 have R_LOG_DIR_IN as the direction field.
// Two of these are only visible for hi capability clients, the other one
// can be viewed by all clients.
expectedEventCount = (TheHiCapability) ? 7 : 1;
CleanupStack::Pop(); // filter
filter = CLogFilter::NewL();
CleanupStack::PushL(filter);
filter->SetDirection(direction);
list->AppendL(filter);
active->StartL();
TEST(view->SetFilterL(*list, active->iStatus));
CActiveScheduler::Start();
TEST(view->CountL() == expectedEventCount);
// clear up...
list->ResetAndDestroy();
CleanupStack::Pop(); // filter
CleanupStack::PopAndDestroy(3); // view, list, active
}
示例11: main
int main(int ac, char **av)
{
int lc;
char *msg;
int results;
/* Disable test if the version of the kernel is less than 2.6.17 */
if (((results = tst_kvercmp(2, 6, 17)) < 0)) {
tst_resm(TWARN, "This test can only run on kernels that are ");
tst_resm(TWARN, "2.6.17 and higher");
exit(0);
}
/*
* parse standard options
*/
if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
/*
* perform global setup for test
*/
setup();
/*
* check if the current filesystem is nfs
*/
if (tst_is_cwd_nfs()) {
tst_brkm(TCONF, cleanup,
"Cannot do tee on a file located on an NFS filesystem");
}
/*
* check looping state if -c option given
*/
for (lc = 0; TEST_LOOPING(lc); lc++) {
Tst_count = 0;
/*
* Call tee_test
*/
TEST(tee_test());
/* check return code */
if (TEST_RETURN < 0) {
if (TEST_RETURN != -1) {
TEST_ERRNO = -TEST_RETURN;
}
TEST_ERROR_LOG(TEST_ERRNO);
tst_resm(TFAIL, "tee() Failed, errno=%d : %s",
TEST_ERRNO, strerror(TEST_ERRNO));
} else {
/*
* only perform functional verification if flag set (-f not given)
*/
if (STD_FUNCTIONAL_TEST) {
/* No Verification test, yet... */
tst_resm(TPASS, "tee() returned %ld",
TEST_RETURN);
}
}
}
/*
* cleanup and exit
*/
cleanup();
return (0);
}
示例12: TestChangeConfigL
/**
@SYMTestCaseID SYSLIB-LOGENG-CT-0126
@SYMTestCaseDesc Change the database configuration
@SYMTestPriority High
@SYMTestActions Low capability clients can't do this
@SYMTestExpectedResults Should always succeed
@SYMREQ REQ3431
*/
LOCAL_C void TestChangeConfigL(CLogClient& aClient)
{
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0126 "));
CTestActive* active = new(ELeave)CTestActive();
CleanupStack::PushL(active);
TLogConfig configOld;
active->StartL();
aClient.GetConfig(configOld, active->iStatus);
CActiveScheduler::Start();
TEST2(active->iStatus.Int(), KErrNone);
TLogConfig config;
#ifdef _DEBUG
TInt failCount = 0;
#endif
TBool finished = EFalse;
TInt error;
while(!finished)
{
error = KErrNone;
config.iMaxLogSize = KTestMaxLogSize;
config.iMaxRecentLogSize = KTestMaxRecentLogSize;
config.iMaxEventAge = KTestMaxEventAge;
__UHEAP_FAILNEXT(failCount++);
aClient.ChangeConfig(config, active->iStatus);
active->StartL();
CActiveScheduler::Start();
if (active->iStatus == KErrNone)
finished = ETrue;
else
error = active->iStatus.Int();
__UHEAP_RESET;
if ((error == KErrNoMemory) || (error == KErrPermissionDenied))
{
active->StartL();
aClient.GetConfig(config, active->iStatus);
CActiveScheduler::Start();
TEST2(active->iStatus.Int(), KErrNone);
TEST(config.iMaxLogSize == configOld.iMaxLogSize);
TEST(config.iMaxRecentLogSize == configOld.iMaxRecentLogSize);
TEST(config.iMaxEventAge == configOld.iMaxEventAge);
}
else
{
TEST2(error, KErrNone);
}
if(! TheHiCapability)
finished = TRUE;
}
if(TheHiCapability)
{
TEST(config.iMaxLogSize == KTestMaxLogSize);
TEST(config.iMaxRecentLogSize == KTestMaxRecentLogSize);
TEST(config.iMaxEventAge == KTestMaxEventAge);
}
else
{
TEST(config.iMaxLogSize == configOld.iMaxLogSize);
TEST(config.iMaxRecentLogSize == configOld.iMaxRecentLogSize);
TEST(config.iMaxEventAge == configOld.iMaxEventAge);
}
CleanupStack::PopAndDestroy(); // active
}
示例13: TestChangeEventTypeL
/**
@SYMTestCaseID SYSLIB-LOGENG-CT-0122
@SYMTestCaseDesc Tries to change existing event types.
@SYMTestActions See the description and expected results.
@SYMTestPriority High
@SYMTestExpectedResults Should always succeed
@SYMREQ REQ3431
*/
LOCAL_C void TestChangeEventTypeL(CLogClient& aClient)
{
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0122 "));
CTestActive* active = new(ELeave)CTestActive();
CleanupStack::PushL(active);
CLogEventType* type = CLogEventType::NewL();
CleanupStack::PushL(type);
type->SetUid(KTestEventUid);
type->SetDescription(KTestEventDesc1);
type->SetDescription(KTestEventDesc2);
#ifdef _DEBUG
TInt failCount = 0;
#endif
TBool finished = EFalse;
TInt error;
while(!finished)
{
error = KErrNone;
type->SetDescription(KTestEventDesc2);
type->SetLoggingEnabled(EFalse);
__UHEAP_FAILNEXT(failCount++);
aClient.ChangeEventType(*type, active->iStatus);
active->StartL();
CActiveScheduler::Start();
if (active->iStatus == KErrNone)
finished = ETrue;
else
error = active->iStatus.Int();
__UHEAP_RESET;
if (error == KErrNoMemory)
{
active->StartL();
aClient.GetEventType(*type, active->iStatus);
CActiveScheduler::Start();
TEST2(active->iStatus.Int(), KErrNone);
TEST(type->Description() == KTestEventDesc1);
TEST(type->LoggingEnabled());
}
else
{
TEST2(error, TheHiCapability ? KErrNone : KErrPermissionDenied);
if(!TheHiCapability)
finished = TRUE;
}
}
type->SetUid(KTestEventUid);
active->StartL();
aClient.GetEventType(*type, active->iStatus);
CActiveScheduler::Start();
TEST2(active->iStatus.Int(), KErrNone);
if(TheHiCapability)
{
TEST(type->Uid() == KTestEventUid);
TEST(type->Description() == KTestEventDesc2);
TEST(type->LoggingEnabled() == EFalse);
}
else
{
TEST(type->Uid() == KTestEventUid);
TEST(type->Description() == KTestEventDesc1);
TEST(type->LoggingEnabled());
}
CleanupStack::PopAndDestroy(2); // type, active
}
示例14: TestBasicL
/**
@SYMTestCaseID SYSLIB-LOGENG-CT-0119
@SYMTestCaseDesc Tests AddEvent, GetEvent, ChangeEvent and DeleteEvent.
@SYMTestPriority High
@SYMTestActions See the description and expected results.
@SYMTestExpectedResults
1. a client with sufficient capability succeed in all cases would expect the following...
AddEvent - KErrNone
GetEvent - KErrNone
ChangeEvent - KErrNone
DeleteEvent - KErrNone
2. a client with insufficient capability would expect the following results...
AddEvent - KErrPermissionDenied
GetEvent - KErrNone
ChangeEvent - KErrPermissionDenied
DeleteEvent - KErrPermissionDenied
@SYMREQ REQ3431
*/
LOCAL_C void TestBasicL(CLogClient& aClient)
{
TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0119 "));
CTestActive* active = new(ELeave)CTestActive();
CleanupStack::PushL(active);
CLogEvent* event = CLogEvent::NewL();
CleanupStack::PushL(event);
TTime now;
now.UniversalTime();
event->SetEventType(KLogCallEventTypeUid);
active->StartL();
aClient.AddEvent(*event, active->iStatus);
CActiveScheduler::Start();
TEST2(active->iStatus.Int(), TheHiCapability ? KErrNone : KErrPermissionDenied);
if(!TheHiCapability)
{
TInt eventId = TestUtils::AddEventL();
TEST(eventId >= 0);
event->SetId(eventId);
}
TEST(event->EventType() == KLogCallEventTypeUid);
now = event->Time();
TLogId id = event->Id();
event->SetRemoteParty(KTestRemoteParty1);
event->SetDirection(KTestDirection1);
event->SetDurationType(KTestDurationType1);
event->SetDuration(KTestDuration1);
event->SetStatus(KTestStatus1);
event->SetSubject(KTestSubject1);
event->SetNumber(KTestNumber1);
event->SetContact(KTestContact1);
event->SetLink(KTestLink1);
event->SetDataL(KTestData1);
active->StartL();
aClient.ChangeEvent(*event, active->iStatus);
CActiveScheduler::Start();
TheTest.Printf(_L("TestBasicL(), TheHiCapability=%d, event id=%d\r\n"), TheHiCapability, id);
TEST2(active->iStatus.Int(), TheHiCapability ? KErrNone : KErrPermissionDenied);
TEST(event->Id() == id );
TEST(event->EventType() == KLogCallEventTypeUid);
if(TheHiCapability)
{
TEST(event->Description().Length() > 0);
TEST(event->Time() == now);
TEST(event->RemoteParty() == KTestRemoteParty1);
TEST(event->Direction() == KTestDirection1);
TEST(event->DurationType() == KTestDurationType1);
TEST(event->Duration() == KTestDuration1);
TEST(event->Status() == KTestStatus1);
TEST(event->Subject() == KTestSubject1);
TEST(event->Number() == KTestNumber1);
TEST(event->Contact() == KTestContact1);
TEST(event->Link() == KTestLink1);
TEST(event->Data() == KTestData1);
}
CleanupStack::PopAndDestroy(); // event;
event = CLogEvent::NewL();
CleanupStack::PushL(event);
event->SetId(id);
active->StartL();
aClient.GetEvent(*event, active->iStatus);
CActiveScheduler::Start();
//.........这里部分代码省略.........
示例15: test_read_2
void test_read_2(void) {
Value value = read_from_str("1x");
TEST(value.type == SYMBOL);
}