예제 #1
0
void tst_inotifytools_snprintf()
{
    ENTER
    verify((0 == mkdir(TEST_DIR, 0700)) || (EEXIST == errno));
    verify(inotifytools_initialize());
    verify(inotifytools_watch_file(TEST_DIR, IN_CLOSE));

#define BUFSZ 2048
#define RESET do { \
        memset(buf, 0, BUFSZ); \
        memset(test_event, 0, sizeof(struct inotify_event)); \
        test_event->wd = inotifytools_wd_from_filename( TEST_DIR "/"); \
        verify( test_event->wd >= 0 ); \
        inotifytools_set_printf_timefmt(0); \
    } while(0)

    char buf[BUFSZ];
    char event_buf[4096];
    struct inotify_event *test_event = (struct inotify_event *)event_buf;

    RESET;
    test_event->mask = IN_ACCESS;
    inotifytools_snprintf(buf, 1024, test_event, "Event %e %.e on %w %f %T");
    verify2(!strcmp(buf, "Event ACCESS ACCESS on " TEST_DIR "/  "), buf);

    RESET;
    test_event->mask = IN_ACCESS | IN_DELETE;
    inotifytools_snprintf(buf, 1024, test_event, "Event %e %.e on %w %f %T");
    verify2(!strcmp(buf, "Event ACCESS,DELETE ACCESS.DELETE on " TEST_DIR "/  ")
            || !strcmp(buf, "Event DELETE,ACCESS DELETE.ACCESS on " TEST_DIR "/  "), buf);

    RESET;
    test_event->mask = IN_MODIFY;
    inotifytools_snprintf(buf, 10, test_event, "Event %e %.e on %w %f %T");
    verify2(!strcmp(buf, "Event MODI"), buf);

    RESET;
    test_event->mask = IN_ACCESS;
    strcpy(test_event->name, "my_great_file");
    test_event->len = strlen(test_event->name) + 1;
    inotifytools_snprintf(buf, 1024, test_event, "Event %e %.e on %w %f %T");
    verify2(!strcmp(buf, "Event ACCESS ACCESS on " TEST_DIR "/ my_great_file "), buf);

    RESET;
    test_event->mask = IN_ACCESS;
    inotifytools_set_printf_timefmt("%D%% %H:%M");
    {
        char expected[1024];
        char timestr[1024];
        time_t now = time(0);
        strftime(timestr, 1024, "%D%% %H:%M", localtime(&now));
        snprintf(expected, 1024, "Event ACCESS ACCESS on %s/  %s", TEST_DIR, timestr);
        inotifytools_snprintf(buf, 1024, test_event, "Event %e %.e on %w %f %T");
        verify2(!strcmp(buf, expected), buf);
    }

#undef BUFSZ
    EXIT
}
void TestFTIndexRebuild::verifyMiscOps(ISession *session)
{
	Value val[4];
	//case 1: META_PROP_NOFTINDEX should be honored
	val[0].set("Wollongabba");val[0].setPropID(mPropIds[1]);
	TVERIFYRC(session->createPIN(val,1,NULL,MODE_PERSISTENT|MODE_COPY_VALUES));
	TVERIFYRC(session->rebuildIndexFT());
	TVERIFY(verify2(session,"Wollongabba",0));

    //case 2: META_PROP_STOPWORDS should be honored
	val[0].set("brisbane is somewhere");val[0].setPropID(mPropIds[1]);	//val[0].meta = META_PROP_STOPWORDS;	-- always excludes stopwords
	TVERIFYRC(session->createPIN(val,1,NULL,MODE_PERSISTENT|MODE_COPY_VALUES));
	TVERIFYRC(session->rebuildIndexFT());
	TVERIFY(verify2(session,"somewhere",0));

    //case 3: PIN_HIDDEN should be honored
	val[0].set("adeleide is somewhere");val[0].setPropID(mPropIds[1]);
	TVERIFYRC(session->createPIN(val,1,NULL,MODE_PERSISTENT|MODE_COPY_VALUES|PIN_HIDDEN));
	TVERIFYRC(session->rebuildIndexFT());
	TVERIFY(verify2(session,"adeleide",0));
	//case 4: Extended char set tests
}
예제 #3
0
void event_to_str()
{
    ENTER
    verify2(
        !strcmp(inotifytools_event_to_str(IN_OPEN | IN_MODIFY | IN_ACCESS),
                "OPEN,MODIFY,ACCESS") ||
        !strcmp(inotifytools_event_to_str(IN_OPEN | IN_MODIFY | IN_ACCESS),
                "OPEN,ACCESS,MODIFY") ||
        !strcmp(inotifytools_event_to_str(IN_OPEN | IN_MODIFY | IN_ACCESS),
                "ACCESS,OPEN,MODIFY") ||
        !strcmp(inotifytools_event_to_str(IN_OPEN | IN_MODIFY | IN_ACCESS),
                "MODIFY,OPEN,ACCESS") ||
        !strcmp(inotifytools_event_to_str(IN_OPEN | IN_MODIFY | IN_ACCESS),
                "ACCESS,MODIFY,OPEN") ||
        !strcmp(inotifytools_event_to_str(IN_OPEN | IN_MODIFY | IN_ACCESS),
                "MODIFY,ACCESS,OPEN")
        , inotifytools_event_to_str(IN_OPEN | IN_MODIFY | IN_ACCESS));
    EXIT
}
예제 #4
0
void event_to_str_sep()
{
    ENTER
    verify2(
        !strcmp(inotifytools_event_to_str_sep(IN_OPEN | IN_MODIFY | IN_ACCESS, ':'),
                "OPEN:MODIFY:ACCESS") ||
        !strcmp(inotifytools_event_to_str_sep(IN_OPEN | IN_MODIFY | IN_ACCESS, ':'),
                "OPEN:ACCESS:MODIFY") ||
        !strcmp(inotifytools_event_to_str_sep(IN_OPEN | IN_MODIFY | IN_ACCESS, ':'),
                "ACCESS:OPEN:MODIFY") ||
        !strcmp(inotifytools_event_to_str_sep(IN_OPEN | IN_MODIFY | IN_ACCESS, ':'),
                "MODIFY:OPEN:ACCESS") ||
        !strcmp(inotifytools_event_to_str_sep(IN_OPEN | IN_MODIFY | IN_ACCESS, ':'),
                "ACCESS:MODIFY:OPEN") ||
        !strcmp(inotifytools_event_to_str_sep(IN_OPEN | IN_MODIFY | IN_ACCESS, ':'),
                "MODIFY:ACCESS:OPEN")
        , inotifytools_event_to_str_sep(IN_OPEN | IN_MODIFY | IN_ACCESS, ':'));
    EXIT
}
예제 #5
0
bool DrasculaEngine::runCurrentChapter() {
	int n;

	rightMouseButton = 0;

	previousMusic = -1;

	if (currentChapter != 2) {
		int soc = 0;
		for (n = 0; n < 6; n++) {
			soc = soc + CHARACTER_WIDTH;
			_frameX[n] = soc;
		}
	}

	for (n = 1; n < ARRAYSIZE(inventoryObjects); n++)
		inventoryObjects[n] = 0;

	for (n = 0; n < NUM_FLAGS; n++)
		flags[n] = 0;

	if (currentChapter == 2) {
		flags[16] = 1;
		flags[17] = 1;
		flags[27] = 1;
	}

	for (n = 1; n < 7; n++)
		inventoryObjects[n] = n;

	if (currentChapter == 1) {
		pickObject(28);

		if (loadedDifferentChapter == 0)
			animation_1_1();

		selectVerb(kVerbNone);
		loadPic("2aux62.alg", drawSurface2);
		trackProtagonist = 1;
		objExit = 104;
		if (loadedDifferentChapter != 0) {
			if (!loadGame(saveName)) {
				return true;
			}
		} else {
			enterRoom(62);
			curX = -20;
			curY = 56;
			gotoObject(65, 145);
		}
	} else if (currentChapter == 2) {
		addObject(kItemPhone);
		trackProtagonist = 3;
		objExit = 162;
		if (loadedDifferentChapter == 0)
			enterRoom(14);
		else {
			if (!loadGame(saveName)) {
				return true;
			}
		}
	} else if (currentChapter == 3) {
		addObject(kItemPhone);
		addObject(kItemEarplugs);
		addObject(kItemSickle);
		addObject(kItemHandbag);
		addObject(kItemCross);
		addObject(kItemReefer);
		addObject(kItemOneCoin);
		flags[1] = 1;
		trackProtagonist = 1;
		objExit = 99;
		if (loadedDifferentChapter == 0)
			enterRoom(20);
		else {
			if (!loadGame(saveName)) {
				return true;
			}
		}
	// From here onwards the items have different IDs
	} else if (currentChapter == 4) {
		addObject(kItemPhone2);
		addObject(kItemCross2);
		addObject(kItemReefer2);
		addObject(kItemOneCoin2);
		objExit = 100;
		if (loadedDifferentChapter == 0) {
			enterRoom(21);
			trackProtagonist = 0;
			curX = 235;
			curY = 164;
		} else {
			if (!loadGame(saveName)) {
				return true;
			}
		}
	} else if (currentChapter == 5) {
		addObject(28);
		addObject(7);
		addObject(9);
		addObject(11);
		addObject(13);
		addObject(14);
		addObject(15);
		addObject(17);
		addObject(20);
		trackProtagonist = 1;
		objExit = 100;
		if (loadedDifferentChapter == 0) {
			enterRoom(45);
		} else {
			if (!loadGame(saveName)) {
				return true;
			}
		}
	} else if (currentChapter == 6) {
		addObject(28);
		addObject(9);

		trackProtagonist = 1;
		objExit = 104;
		if (loadedDifferentChapter == 0) {
			enterRoom(58);
			animation_1_6();
		} else {
			if (!loadGame(saveName)) {
				return true;
			}
			loadPic("auxdr.alg", drawSurface2);
		}
	}

	showCursor();

	while (!shouldQuit()) {
		if (characterMoved == 0) {
			stepX = STEP_X;
			stepY = STEP_Y;
		}
		if (characterMoved == 0 && walkToObject == 1) {
			trackProtagonist = trackFinal;
			walkToObject = 0;
		}

		if (currentChapter == 2) {
			// NOTE: the checks for room number 14 below are a hack used in the original
			// game, and move the character to a place where his feet are not drawn above
			// the pianist's head. Originally, walkToObject was not updated properly, which
			// lead to an incorrect setting of the protagonist's tracking flag (above). This
			// made the character start walking off screen, as his actual position was
			// different than the displayed one
			if (roomNumber == 3 && (curX == 279) && (curY + curHeight == 101)) {
				gotoObject(178, 121);
				gotoObject(169, 135);
			} else if (roomNumber == 14 && (curX == 214) && (curY + curHeight == 121)) {
				walkToObject = 1;
				gotoObject(190, 130);
			} else if (roomNumber == 14 && (curX == 246) && (curY + curHeight == 112)) {
				walkToObject = 1;
				gotoObject(190, 130);
			}
		}

		moveCursor();
		updateScreen();

		if (currentChapter == 2) {
			if (musicStatus() == 0 && roomMusic != 0)
				playMusic(roomMusic);
		} else {
			if (musicStatus() == 0)
				playMusic(roomMusic);
		}

		delay(25);
#ifndef _WIN32_WCE
		// FIXME
		// This and the following #ifndefs disable the excess updateEvents() calls *within* the game loop.
		// Events such as keypresses or mouse clicks are dropped on the ground with no processing
		// by these calls. They are properly handled by the implicit call through getScan() below.
		// It is not a good practice to not process events and indeed this created problems with synthesized
		// events in the wince port.
		updateEvents();
#endif

		if (!_menuScreen && takeObject == 1)
			checkObjects();

#ifdef _WIN32_WCE
		if (rightMouseButton)
			if (_menuScreen) {
#else
		if (rightMouseButton == 1 && _menuScreen) {
#endif
			rightMouseButton = 0;
			delay(100);
			if (currentChapter == 2) {
				loadPic(menuBackground, cursorSurface);
				loadPic(menuBackground, backSurface);
			} else {
				loadPic(99, cursorSurface);
				loadPic(99, backSurface);
			}
			setPalette((byte *)&gamePalette);
			_menuScreen = false;
#ifndef _WIN32_WCE
			// FIXME: This call here is in hope that it will catch the rightmouseup event so the
			// next if block won't be executed. This too is not a good coding practice. I've recoded it
			// with a mutual exclusive if block for the menu. I would commit this properly but I cannot test
			// for other (see Desktop) ports right now.
			updateEvents();
#endif
#ifdef _WIN32_WCE
			} else {
#else
		}

		// Do not show the inventory screen in chapter 5, if the right mouse button is clicked
		// while the plug (object 16) is held
		// Fixes bug #2059621 - "DRASCULA: Plug bug"
		if (rightMouseButton == 1 && !_menuScreen &&
			!(currentChapter == 5 && pickedObject == 16)) {
#endif
			rightMouseButton = 0;
			delay(100);
			characterMoved = 0;
			if (trackProtagonist == 2)
				trackProtagonist = 1;
			if (currentChapter == 4) {
				loadPic("icons2.alg", backSurface);
				loadPic("icons2.alg", cursorSurface);
			} else if (currentChapter == 5) {
				loadPic("icons3.alg", backSurface);
				loadPic("icons3.alg", cursorSurface);
			} else if (currentChapter == 6) {
				loadPic("iconsp.alg", backSurface);
				loadPic("iconsp.alg", cursorSurface);
			} else {
				loadPic("icons.alg", backSurface);
				loadPic("icons.alg", cursorSurface);
			}
			_menuScreen = true;
#ifndef _WIN32_WCE
			updateEvents();
#endif
			selectVerb(kVerbNone);
		}

		if (leftMouseButton == 1 && _menuBar) {
			delay(100);
			selectVerbFromBar();
		} else if (leftMouseButton == 1 && takeObject == 0) {
			delay(100);
			if (verify1())
				return true;
		} else if (leftMouseButton == 1 && takeObject == 1) {
			if (verify2())
				return true;
		}

		_menuBar = (mouseY < 24 && !_menuScreen) ? true : false;

		Common::KeyCode key = getScan();
		if (key == Common::KEYCODE_F1 && !_menuScreen) {
			selectVerb(kVerbLook);
		} else if (key == Common::KEYCODE_F2 && !_menuScreen) {
			selectVerb(kVerbPick);
		} else if (key == Common::KEYCODE_F3 && !_menuScreen) {
			selectVerb(kVerbOpen);
		} else if (key == Common::KEYCODE_F4 && !_menuScreen) {
			selectVerb(kVerbClose);
		} else if (key == Common::KEYCODE_F5 && !_menuScreen) {
			selectVerb(kVerbTalk);
		} else if (key == Common::KEYCODE_F6 && !_menuScreen) {
			selectVerb(kVerbMove);
		} else if (key == Common::KEYCODE_F9) {
			volumeControls();
		} else if (key == Common::KEYCODE_F10) {
			if (!saveLoadScreen())
				return true;
		} else if (key == Common::KEYCODE_F8) {
			selectVerb(kVerbNone);
		} else if (key == Common::KEYCODE_v) {
			_subtitlesDisabled = true;
			ConfMan.setBool("subtitles", !_subtitlesDisabled);

			print_abc(_textsys[2], 96, 86);
			updateScreen();
			delay(1410);
		} else if (key == Common::KEYCODE_t) {
			_subtitlesDisabled = false;
			ConfMan.setBool("subtitles", !_subtitlesDisabled);

			print_abc(_textsys[3], 94, 86);
			updateScreen();
			delay(1460);
		} else if (key == Common::KEYCODE_ESCAPE) {
			if (!confirmExit())
				return false;
		} else if (key == Common::KEYCODE_TILDE || key == Common::KEYCODE_BACKQUOTE) {
			_console->attach();
			_console->onFrame();
		} else if (currentChapter == 6 && key == Common::KEYCODE_0 && roomNumber == 61) {
			loadPic("alcbar.alg", bgSurface, 255);
		}

		if (leftMouseButton != 0 || rightMouseButton != 0 || key != 0)
			if (currentChapter != 3)
				framesWithoutAction = 0;

		if (framesWithoutAction == 15000) {
			screenSaver();
			if (currentChapter != 3)
				framesWithoutAction = 0;
		}

		if (currentChapter != 3)
			framesWithoutAction++;
	}

	return false;
}


bool DrasculaEngine::verify1() {
	int l;

	if (_menuScreen)
		removeObject();
	else {
		for (l = 0; l < numRoomObjs; l++) {
			if (mouseX >= x1[l] && mouseY >= y1[l]
					&& mouseX <= x2[l] && mouseY <= y2[l] && doBreak == 0) {
				if (exitRoom(l))
					return true;
				if (doBreak == 1)
					break;
			}
		}

		if (mouseX > curX && mouseY > curY
				&& mouseX < curX + curWidth && mouseY < curY + curHeight)
			doBreak = 1;

		for (l = 0; l < numRoomObjs; l++) {
			if (mouseX > x1[l] && mouseY > y1[l]
					&& mouseX < x2[l] && mouseY < y2[l] && doBreak == 0) {
				roomX = roomObjX[l];
				roomY = roomObjY[l];
				trackFinal = trackObj[l];
				doBreak = 1;
				walkToObject = 1;
				startWalking();
			}
		}

		if (doBreak == 0) {
			roomX = CLIP(mouseX, floorX1, floorX2);
			roomY = CLIP(mouseY, floorY1 + feetHeight, floorY2);
			startWalking();
		}
		doBreak = 0;
	}

	return false;
}
예제 #6
0
int main() {
   int x = 0 ? foo() : bar(5);
	return (0 ?
		verify2(0) :
		verify());
}
예제 #7
0
파일: multidemo.c 프로젝트: TRANE73/sort
void run_tests2(void)
{
  int i;
  int64_t arr[SIZE];
  int64_t dst[SIZE];
  double start_time;
  double end_time;
  double total_time;

  printf("Running tests - 2\n");
  srand48(SEED);
  total_time = 0.0;
  for (i = 0; i < RUNS; i++) {
    fill(arr, SIZE);
    memcpy(dst, arr, sizeof(int64_t) * SIZE);
    start_time = utime();

    qsort(dst, SIZE, sizeof(int64_t), simple_cmp2);

    end_time = utime();
    total_time += end_time - start_time;
    verify2(dst, SIZE);
  }
  printf("stdlib qsort time: %.2f us per iteration\n", total_time / RUNS);

#ifndef __linux__
  srand48(SEED);
  total_time = 0.0;
  for (i = 0; i < RUNS; i++) {
    fill(arr, SIZE);
    memcpy(dst, arr, sizeof(int64_t) * SIZE);
    start_time = utime();

    heapsort(dst, SIZE, sizeof(int64_t), simple_cmp2);

    end_time = utime();
    total_time += end_time - start_time;
    verify2(dst, SIZE);
  }
  printf("stdlib heapsort time: %.2f us per iteration\n", total_time / RUNS);

  srand48(SEED);
  total_time = 0.0;
  for (i = 0; i < RUNS; i++) {
    fill(arr, SIZE);
    memcpy(dst, arr, sizeof(int64_t) * SIZE);
    start_time = utime();

    mergesort(dst, SIZE, sizeof(int64_t), simple_cmp2);

    end_time = utime();
    total_time += end_time - start_time;
    verify2(dst, SIZE);
  }
  printf("stdlib mergesort time: %.2f us per iteration\n", total_time / RUNS);
#endif

  srand48(SEED);
  total_time = 0.0;
  for (i = 0; i < RUNS; i++) {
    fill(arr, SIZE);
    memcpy(dst, arr, sizeof(int64_t) * SIZE);
    start_time = utime();

    sorter2_quick_sort(dst, SIZE);

    end_time = utime();
    total_time += end_time - start_time;
    verify2(dst, SIZE);
  }
  printf("quick sort time: %.2f us per iteration\n", total_time / RUNS);


  srand48(SEED);
  total_time = 0.0;
  for (i = 0; i < RUNS; i++) {
    fill(arr, SIZE);
    memcpy(dst, arr, sizeof(int64_t) * SIZE);
    start_time = utime();

    sorter2_bubble_sort(dst, SIZE);

    end_time = utime();
    total_time += end_time - start_time;
    verify2(dst, SIZE);
  }
  printf("bubble sort time: %.2f us per iteration\n", total_time / RUNS);

  srand48(SEED);
  total_time = 0.0;
  for (i = 0; i < RUNS; i++) {
    fill(arr, SIZE);
    memcpy(dst, arr, sizeof(int64_t) * SIZE);
    start_time = utime();

    sorter2_merge_sort(dst, SIZE);

    end_time = utime();
    total_time += end_time - start_time;
    verify2(dst, SIZE);
  }
  printf("merge sort time: %.2f us per iteration\n", total_time / RUNS);

  srand48(SEED);
  total_time = 0.0;
  for (i = 0; i < RUNS; i++) {
    fill(arr, SIZE);
    memcpy(dst, arr, sizeof(int64_t) * SIZE);
    start_time = utime();

    sorter2_binary_insertion_sort(dst, SIZE);

    end_time = utime();
    total_time += end_time - start_time;
    verify2(dst, SIZE);
  }
  printf("binary insertion sort time: %.2f us per iteration\n", total_time / RUNS);

  srand48(SEED);
  total_time = 0.0;
  for (i = 0; i < RUNS; i++) {
    fill(arr, SIZE);
    memcpy(dst, arr, sizeof(int64_t) * SIZE);
    start_time = utime();

    sorter2_heap_sort(dst, SIZE);

    end_time = utime();
    total_time += end_time - start_time;
    verify2(dst, SIZE);
  }
  printf("heap sort time: %.2f us per iteration\n", total_time / RUNS);

  srand48(SEED);
  total_time = 0.0;
  for (i = 0; i < RUNS; i++) {
    fill(arr, SIZE);
    memcpy(dst, arr, sizeof(int64_t) * SIZE);
    start_time = utime();

    sorter2_shell_sort(dst, SIZE);

    end_time = utime();
    total_time += end_time - start_time;
    verify2(dst, SIZE);
  }
  printf("shell sort time: %.2f us per iteration\n", total_time / RUNS);

  srand48(SEED);
  total_time = 0.0;
  for (i = 0; i < RUNS; i++) {
    fill(arr, SIZE);
    memcpy(dst, arr, sizeof(int64_t) * SIZE);
    start_time = utime();

    sorter2_tim_sort(dst, SIZE);

    end_time = utime();
    total_time += end_time - start_time;
    verify2(dst, SIZE);
  }
  printf("tim sort time: %.2f us per iteration\n", total_time / RUNS);
}
예제 #8
0
int main(void)
{
    verify2(list_one, list_two, 8, 5);
    return 0;
}