• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ setup函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中setup函数的典型用法代码示例。如果您正苦于以下问题:C++ setup函数的具体用法?C++ setup怎么用?C++ setup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了setup函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main


//.........这里部分代码省略.........

        switch (argv[i][1]) {
        case 'g':
            if (i >= argc - 1)
                break;
            bitm = XParseGeometry(argv[i+1], &xr, &yr, &wr, &hr);
            if (bitm & XValue)
                wx = xr;
            if (bitm & YValue)
                wy = yr;
            if (bitm & WidthValue)
                ww = (int)wr;
            if (bitm & HeightValue)
                wh = (int)hr;
            if (bitm & XNegative && wx == 0)
                wx = -1;
            if (bitm & YNegative && wy == 0)
                wy = -1;
            i++;
            break;
        case 'h':
            switch ((i >= argc - 1)? 0 : argv[i][2]) {
            case 's':
                heightscaling = atof(argv[i+1]);
                i++;
                break;
            default:
                usage(argv[0]);
            }
            break;
        case 'o':
            horizontal = True;
            break;
        case 's':
            oneshot = 0;
            break;
        case 'w':
            switch ((i >= argc - 1)? 0 : argv[i][2]) {
            case 's':
                widthscaling = atof(argv[i+1]);
                i++;
                break;
            default:
                usage(argv[0]);
            }
            break;
        case 'x':
            addexit = False;
            break;
        default:
            usage(argv[0]);
        }
    }

    for (; argv[i]; i++) {
        label = argv[i];
        if (!argv[i+1])
            break;
        i++;
        cmd = argv[i];

        entries = realloc(entries, sizeof(entries[0])*(++nentries));
        entries[nentries-1] = malloc(sizeof(*entries[0]));
        memset(entries[nentries-1], 0, sizeof(*entries[0]));

        entries[nentries-1]->label = strdup(label);
        if (entries[nentries-1]->label == NULL)
            die("strdup returned NULL\n");
        entries[nentries-1]->cmd = strdup(cmd);
        if (entries[nentries-1]->cmd == NULL)
            die("strdup returned NULL\n");
    }
    if (nentries < 1)
        usage(argv[0]);

    if (addexit) {
        entries = realloc(entries, sizeof(entries[0])*(++nentries));
        entries[nentries-1] = malloc(sizeof(*entries[0]));
        memset(entries[nentries-1], 0, sizeof(*entries[0]));
        entries[nentries-1]->label = strdup("cancel");
        entries[nentries-1]->cmd = "exit";
        entries[nentries-1]->forceexit = True;
    }

    if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())
        fprintf(stderr, "warning: no locale support\n");
    if(!(dpy = XOpenDisplay(0)))
        die("thingmenu: cannot open display\n");

    setup();
    run();
    cleanup();
    XCloseDisplay(dpy);

    for (i = 0; i < nentries; i++)
        free(entries[i]);
    free(entries);

    return 0;
}
开发者ID:singpolyma,项目名称:thingmenu,代码行数:101,代码来源:thingmenu.c


示例2: switch

/** Handle tab completion.
    * User interface uses a dual model, first tab completes upto the
    * longest common (case insensitiv) match, further tabbing cycles through all
    * possible completions. When doing a tab completion without something to complete
    * possibly offers a special guess first.
    */
void TabCompletion::tryComplete() {
    switch (typingStatus_) {
        case TypingStatus::Normal:
            typingStatus_ = TypingStatus::TabPressed;
            break;
        case TypingStatus::TabPressed:
            typingStatus_ = TypingStatus::TabbingCompletions;
            break;
        default:
            break;
    }


    QString newText;
    bool replaced = false;

    if (typingStatus_ == TypingStatus::MultipleSuggestions) {
        if (!suggestedCompletion_.isEmpty()) {
            suggestedIndex_++;
            if (suggestedIndex_ >= (int)suggestedCompletion_.count()) {
                suggestedIndex_ = 0;
            }
            newText = suggestedCompletion_[suggestedIndex_];
            replaced = true;
        }
    } else {
        QTextCursor cursor = textEdit_->textCursor();
        QString wholeText = textEdit_->toPlainText();

        int begin, end;
        setup(wholeText, cursor.position(), begin, end);
        replacementCursor_ = QTextCursor(textEdit_->document());
        moveCursorToOffset(replacementCursor_, begin);
        moveCursorToOffset(replacementCursor_, end, QTextCursor::KeepAnchor);

        if (toComplete_.isEmpty() && typingStatus_ == TypingStatus::TabbingCompletions) {
            typingStatus_ = TypingStatus::MultipleSuggestions;

            QString guess;
            suggestedCompletion_ = allChoices(guess);

            if ( !guess.isEmpty() ) {
                suggestedIndex_ = -1;
                newText = guess;
                replaced = true;
            } else if (!suggestedCompletion_.isEmpty()) {
                suggestedIndex_ = 0;
                newText = suggestedCompletion_.first();
                replaced = true;
            }
        } else {
            newText = suggestCompletion(&replaced);
        }
    }

    if (replaced) {
        textEdit_->setUpdatesEnabled(false);

        int start = qMin(replacementCursor_.anchor(), replacementCursor_.position());

        replacementCursor_.beginEditBlock();
        replacementCursor_.insertText(newText);
        replacementCursor_.endEditBlock();

        QTextCursor newPos(replacementCursor_);

        moveCursorToOffset(replacementCursor_, start, QTextCursor::KeepAnchor);


        newPos.clearSelection();

        textEdit_->setTextCursor(newPos);

        textEdit_->setUpdatesEnabled(true);
        textEdit_->viewport()->update();
    }
    highlight(typingStatus_ == TypingStatus::MultipleSuggestions);
}
开发者ID:psi-im,项目名称:psi,代码行数:84,代码来源:tabcompletion.cpp


示例3: setup

ofxGuiGroup::ofxGuiGroup(const ofParameterGroup & parameters, string filename, float x, float y){
	minimized = false;
	parent = NULL;
    setup(parameters, filename, x, y);
}
开发者ID:cpietsch,项目名称:gesichtet,代码行数:5,代码来源:ofxGuiGroup.cpp


示例4: setup

int AXWindow::run(){
    if(setup){
        setup();
    }
    if(activeScene){
        activeScene->start();
    }
    SDL_Event event;
    bool inFocus = true;
    while(go == 1){
        AXWindow::frameCount++;
        AXWindow::deltaTime = SDL_GetPerformanceCounter() - AXWindow::previousDeltaTime;
        AXWindow::previousDeltaTime = SDL_GetPerformanceCounter();
        while(SDL_PollEvent(&event) != 0 ){
            //User requests quit
            if(event.type == SDL_QUIT){
                go = 0;
                break;
            }else if( event.type == SDL_KEYDOWN){
                const std::string& temp = AXInput::setKeyDown(event.key.keysym.scancode);
                if(activeScene){
                    activeScene->inputChange(temp, 1);
                }
            }else if(event.type == SDL_KEYUP){
                const std::string& temp = AXInput::setKeyUp(event.key.keysym.scancode);
                if(activeScene){
                    activeScene->inputChange(temp, 0);
                }
            }else if(event.type == SDL_MOUSEMOTION){
                AXInput::mouseX = event.motion.x;
                AXInput::mouseY = event.motion.y;
            }else if(event.type == SDL_MOUSEBUTTONDOWN){
                const std::string& temp = AXInput::mousePressed(event.button.button);
                if(activeScene){
                    activeScene->inputChange(temp, 1);
                }
            }else if(event.type == SDL_MOUSEBUTTONUP){
                const std::string& temp = AXInput::mouseReleased(event.button.button);
                if(activeScene){
                    activeScene->inputChange(temp, 0);
                }
            }else if(event.type == SDL_CONTROLLERBUTTONDOWN){
                const std::string& temp = AXInput::setKeyDown((SDL_GameControllerButton)event.cbutton.button+(AX_INPUT_CONTROLLER_OFFSET*(event.cdevice.which+1)));
                if(activeScene){
                    activeScene->inputChange(temp, 1);
                }

            }else if(event.type == SDL_CONTROLLERBUTTONUP){
                const std::string& temp = AXInput::setKeyUp((SDL_GameControllerButton)event.cbutton.button+(AX_INPUT_CONTROLLER_OFFSET*(event.cdevice.which+1)));
                if(activeScene){
                    activeScene->inputChange(temp, 0);
                }
            }else if(event.type == SDL_CONTROLLERDEVICEADDED){
                AXInput::controllers[event.cdevice.which] = SDL_GameControllerOpen(event.cdevice.which);
            }else if(event.type == SDL_CONTROLLERDEVICEREMOVED){
                SDL_GameControllerClose(AXInput::controllers[event.cdevice.which]);
                AXInput::controllers[event.cdevice.which] = 0;
            }else if(event.type == SDL_CONTROLLERAXISMOTION){
                AXInput::setAxisValue(AX_INPUT_CONTROLLER_AXIS_OFFSET+event.caxis.axis+AX_INPUT_CONTROLLER_OFFSET*(event.caxis.which+1), event.caxis.value);
            }else if(event.type == SDL_WINDOWEVENT){
                if(event.window.event == SDL_WINDOWEVENT_FOCUS_GAINED){
                    inFocus = true;
                }else if(event.window.event == SDL_WINDOWEVENT_FOCUS_LOST){
                    inFocus = false;
                }
            }
        }
        if(inFocus){
            if(update){
                update();
            }
            if(activeScene) {
                activeScene->update();
            }
        }
        //Fill the surface wshite
        SDL_SetRenderDrawColor(AXWindow::renderer, backgroundColour.getR(), backgroundColour.getG(), backgroundColour.getB(), backgroundColour.getA());
        SDL_RenderClear(AXWindow::renderer);
        if(inFocus){
            SDL_SetRenderDrawColor(AXWindow::renderer, renderColour.getR(), renderColour.getG(), renderColour.getB(), renderColour.getA());
            if(draw){
                draw();
            }
            if(activeScene) {
                activeScene->draw();
            }
        }
        SDL_RenderPresent(AXWindow::renderer);
    }
    SDL_DestroyWindow(window);
    SDL_DestroyRenderer(renderer);
    //quit the SDLMix
    if(audioStatus){
        while(Mix_Init(0)){
            Mix_Quit();
        }
        Mix_CloseAudio();
    }
    //Quit SDL subsystems
    SDL_Quit();
//.........这里部分代码省略.........
开发者ID:vexparadox,项目名称:cFMake,代码行数:101,代码来源:AXWindow.cpp


示例5: main

int main(int argc, char *argv[])
{
	int status;
	struct semid_ds buf_ds;

	union semun arg;

	setup();

	arg.buf = &buf_ds;
	if ((status = semctl(semid, 0, IPC_STAT, arg)) == -1) {
		tst_resm(TFAIL, "semctl() failed errno = %d", errno);
		semctl(semid, 1, IPC_RMID, arg);

	}

	/*
	 * Check contents of semid_ds structure.
	 */

	if (arg.buf->sem_nsems != nsems) {
		tst_resm(TFAIL, "error: unexpected number of sems %lu",
			 arg.buf->sem_nsems);

	}
	if (arg.buf->sem_perm.uid != getuid()) {
		tst_resm(TFAIL, "error: unexpected uid %d",
			 arg.buf->sem_perm.uid);

	}
	if (arg.buf->sem_perm.gid != getgid()) {
		tst_resm(TFAIL, "error: unexpected gid %d",
			 arg.buf->sem_perm.gid);

	}
	if (arg.buf->sem_perm.cuid != getuid()) {
		tst_resm(TFAIL, "error: unexpected cuid %d",
			 arg.buf->sem_perm.cuid);

	}
	if (arg.buf->sem_perm.cgid != getgid()) {
		tst_resm(TFAIL, "error: unexpected cgid %d",
			 arg.buf->sem_perm.cgid);

	}
	if ((status = semctl(semid, 0, GETVAL, arg)) == -1) {
		tst_resm(TFAIL, "semctl(GETVAL) failed errno = %d", errno);

	}
	arg.val = 1;
	if ((status = semctl(semid, 0, SETVAL, arg)) == -1) {
		tst_resm(TFAIL, "SEMCTL(SETVAL) failed errno = %d", errno);

	}
	if ((status = semctl(semid, 0, GETVAL, arg)) == -1) {
		tst_resm(TFAIL, "semctl(GETVAL) failed errno = %d", errno);

	}
	if (status != arg.val) {
		tst_resm(TFAIL, "error: unexpected value %d", status);

	}
	if ((status = semctl(semid, 0, GETPID, arg)) == -1) {
		tst_resm(TFAIL, "semctl(GETPID) failed errno = %d", errno);

	}
	status = getpid();
	if (status == 0) {
		tst_resm(TFAIL, "error: unexpected pid %d", status);

	}
	if ((status = semctl(semid, 0, GETNCNT, arg)) == -1) {
		tst_resm(TFAIL, "semctl(GETNCNT) failed errno = %d", errno);

	}
	if (status != 0) {
		tst_resm(TFAIL, "error: unexpected semncnt %d", status);

	}
	if ((status = semctl(semid, 0, GETZCNT, arg)) == -1) {
		tst_resm(TFAIL, "semctl(GETZCNT) failed errno = %d", errno);

	}
	if (status != 0) {
		tst_resm(TFAIL, "error: unexpected semzcnt %d", status);

	}

	tst_resm(TPASS, "semctl07 ran successfully!");

	cleanup();
	tst_exit();
}
开发者ID:1587,项目名称:ltp,代码行数:93,代码来源:semctl07.c


示例6: assert

  void BitVector_Test::Test_bitVectorPopulationCount()
  {
    {
      const u32 SIZE =  0;
      BitVector<SIZE> bits;
      assert(bits.PopulationCount() == 0);
      for (u32 i = 0; i < SIZE; ++i) 
      {
        bits.SetBit(i);
        assert(bits.PopulationCount() == i + 1);
      }
    }
    {
      const u32 SIZE =  1;
      BitVector<SIZE> bits;
      assert(bits.PopulationCount() == 0);
      for (u32 i = 0; i < SIZE; ++i) 
      {
        bits.SetBit(i);
        assert(bits.PopulationCount() == i + 1);
      }
    }
    {
      const u32 SIZE =  31;
      BitVector<SIZE> bits;
      assert(bits.PopulationCount() == 0);
      for (u32 i = 0; i < SIZE; ++i) 
      {
        bits.SetBit(i);
        assert(bits.PopulationCount() == i + 1);
      }
    }
    {
      const u32 SIZE =  32;
      BitVector<SIZE> bits;
      assert(bits.PopulationCount() == 0);
      for (u32 i = 0; i < SIZE; ++i) 
      {
        bits.SetBit(i);
        assert(bits.PopulationCount() == i + 1);
      }
    }
    {
      const u32 SIZE =  35;
      BitVector<SIZE> bits;
      assert(bits.PopulationCount() == 0);
      for (u32 i = 0; i < SIZE; ++i) 
      {
        bits.SetBit(i);
        assert(bits.PopulationCount() == i + 1);
      }

    }
    {
      const u32 SIZE =  67;
      BitVector<SIZE> bits;
      assert(bits.PopulationCount() == 0);
      for (u32 i = 0; i < SIZE; ++i) 
      {
        bits.SetBit(i);
        assert(bits.PopulationCount() == i + 1);
      }

      // all combinations of start and len..
      BitVector<SIZE> zbits;

      for (u32 start = 0; start < SIZE; ++start) 
      {
        for (u32 end = start; end < SIZE; ++end) 
        {
          u32 len = end - start + 1;
          assert(bits.PopulationCount(start, len) == len);
          assert(zbits.PopulationCount(start, len) == 0);
        }
      }

    }

    {
      const u32 SIZE =  258;
      BitVector<SIZE> bits;
      assert(bits.PopulationCount() == 0);
      for (u32 i = 0; i < SIZE; ++i) 
      {
        bits.SetBit(SIZE - i - 1);
        assert(bits.PopulationCount() == i + 1);
      }

      assert(bits.PopulationCount() == SIZE);

      for (u32 i = 0; i < SIZE; ++i) 
      {
        bits.ClearBit(i);
        assert(bits.PopulationCount() == SIZE - (i + 1));
      }
    }

    {
      BitVector<256>* bits = setup();
      assert(bits->PopulationCount() == 115);
//.........这里部分代码省略.........
开发者ID:DaveAckley,项目名称:MFM,代码行数:101,代码来源:BitVector_Test.cpp


示例7: setup

//-------------------------------------------
blobTracker::blobTracker() {
    setup(500);
}
开发者ID:jugandoconnumeros,项目名称:jugglerTracker,代码行数:4,代码来源:blobTracker.cpp


示例8: connect_post_start

/* FIXME: this is only used by solver code since matrix solvers are started in
 *        post_start.
 */
void device_t::connect_post_start(detail::core_terminal_t &t1, detail::core_terminal_t &t2)
{
	if (!setup().connect(t1, t2))
		log().fatal(MF_ERROR_CONNECTING_1_TO_2(t1.name(), t2.name()));
}
开发者ID:rfka01,项目名称:mame,代码行数:8,代码来源:nl_base.cpp


示例9: setup

Menu::Menu(sf::RenderWindow* window){
    this->menuWindow = window;
    this->menuOptions = play;
    setup();
}
开发者ID:LaughingCabbage,项目名称:Asteroid,代码行数:5,代码来源:Menu.cpp


示例10: setup

void device_t::connect(detail::core_terminal_t &t1, detail::core_terminal_t &t2)
{
	setup().register_link_fqn(t1.name(), t2.name());
}
开发者ID:rfka01,项目名称:mame,代码行数:4,代码来源:nl_base.cpp


示例11: main

int main(int argc, char **argv)
{
	register int i, pid;
	int count, child, status, nwait;

#ifdef UCLINUX
	const char *msg;
	if ((msg = parse_opts(argc, argv, NULL, NULL)) != NULL)
		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);

	argv0 = argv[0];
	maybe_run_child(&do_child, "dS", &id_uclinux, &maxsemstring);
#endif

	prog = argv[0];
	nwait = 0;
	setup();

	tid = -1;

	for (i = 0; i < NPROCS; i++)
		keyarray[i] = getipckey();

	if ((signal(SIGTERM, term)) == SIG_ERR) {
		tst_resm(TFAIL, "\tsignal failed. errno = %d", errno);

	}

	for (i = 0; i < NPROCS; i++) {
		if ((pid = FORK_OR_VFORK()) < 0) {
			tst_resm(TFAIL,
				 "\tFork failed (may be OK if under stress)");

		}
		if (pid == 0) {
			procstat = 1;
			dotest(keyarray[i]);
			exit(0);
		}
		pidarray[i] = pid;
		nwait++;
	}

	/*
	 * Wait for children to finish.
	 */

	count = 0;
	while ((child = wait(&status)) > 0) {
		if (status) {
			tst_resm(TFAIL, "%s[%d] Test failed.  exit=0x%x", prog,
				 child, status);
			local_flag = FAILED;
		}
		++count;
	}

	/*
	 * Should have collected all children.
	 */

	if (count != nwait) {
		tst_resm(TFAIL, "\tWrong # children waited on, count = %d",
			 count);
		local_flag = FAILED;
	}

	if (local_flag != FAILED)
		tst_resm(TPASS, "semctl06 ran successfully!");
	else
		tst_resm(TFAIL, "semctl06 failed");


	cleanup();
	tst_exit();
}
开发者ID:Nudiv,项目名称:ltp,代码行数:76,代码来源:semctl06.c


示例12: main

int main(int ac, char **av)
{
	int lc;
	char *msg;
	struct stat buf, buf1;
	pid_t pid, pid1;
	struct passwd *ltpuser1;
	struct passwd *ltpuser2;
	int rval, status;

	/*
	 * 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 looping state if -i option given
	 */
	for (lc = 0; TEST_LOOPING(lc); lc++) {

		tst_count = 0;

		/* check the inherited group ID */

		/*
		 * first, fork the first child, set to ltpuser1's uid and gid,
		 * create a directory, with S_ISGID bit set
		 */

		ltpuser1 = my_getpwnam(user1name);
		sprintf(tstdir1, "tstdir1.%d", getpid());

		if ((pid = FORK_OR_VFORK()) < 0) {
			tst_brkm(TFAIL, cleanup, "fork() failed");

		}

		if (pid == 0) {	/* first child */
			rval = setregid(ltpuser1->pw_gid, ltpuser1->pw_gid);
			if (rval < 0) {
				perror("setregid");
				tst_resm(TFAIL, "setregid failed to "
					 "to set the real gid to %d and "
					 "effective gid to %d",
					 ltpuser1->pw_gid, ltpuser1->pw_gid);
				exit(1);

			}
			/* being ltupuser1 */
			rval = setreuid(ltpuser1->pw_uid, ltpuser1->pw_uid);
			if (rval < 0) {
				perror("setreuid");
				tst_resm(TFAIL, "setreuid failed to "
					 "to set the real uid to %d and "
					 "effective uid to %d",
					 ltpuser1->pw_uid, ltpuser1->pw_uid);
				exit(1);

			}

			/*
			 * create a direcoty with S_ISGID bit set
			 * and the group ID is ltpuser1
			 */
			if (mkdir(tstdir1, PERMS) != 0) {
				perror("mkdir");
				tst_resm(TFAIL, "mkdir() failed to create"
					 " a directory with Set "
					 " group ID turn on ");
				exit(1);

			}
			if (stat(tstdir1, &buf1) == -1) {
				perror("stat");
				tst_resm(TFAIL,
					 "failed to stat the new directory"
					 "in mkdir()");
				exit(1);

			}
			if (chmod(tstdir1, buf1.st_mode | S_ISGID) != 0) {
				perror("chmod");
				tst_resm(TFAIL, "failed to set S_ISGID bit");
				exit(1);

			}

			/* Successfully create the parent directory */
			exit(0);

		}
		wait(&status);
		if (WEXITSTATUS(status) != 0) {
//.........这里部分代码省略.........
开发者ID:GOEUM,项目名称:ltp,代码行数:101,代码来源:mkdir02.c


示例13: main

int main(int ac, char **av)
{
	int lc;
	char *msg;

	int ind;
	int offset;

    /***************************************************************
     * 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();

	/* set the expected errnos... */
	TEST_EXP_ENOS(exp_enos);

    /***************************************************************
     * check looping state if -c option given
     ***************************************************************/
	for (lc = 0; TEST_LOOPING(lc); lc++) {

		Tst_count = 0;

		offset = (lc % 100) * 4096;	/* max size is 100 blocks */

		for (ind = 0; Whence[ind] >= 0; ind++) {

			/*
			 *  Call lseek(2)
			 */
			TEST(lseek(Fd, (long)offset, Whence[ind]));

			/* check return code */
			if (TEST_RETURN == -1) {
				TEST_ERROR_LOG(TEST_ERRNO);
				tst_resm(TFAIL,
					 "lseek(%s, %d, 0) Failed, errno=%d : %s",
					 Fname, offset, 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,
						 "lseek(%s, %d, %d) returned %ld",
						 Fname, offset, Whence[ind],
						 TEST_RETURN);
				} else
					Tst_count++;
			}
		}

	}

    /***************************************************************
     * cleanup and exit
     ***************************************************************/
	cleanup();
	tst_exit();

}
开发者ID:Nan619,项目名称:ltp-ddt,代码行数:72,代码来源:lseek01.c


示例14: main

int main(int ac, char *av[])
{
	int ret;
	struct stat buf;
	struct group *group;
	struct passwd *user1;
	char DIR_A[MSGSIZE], DIR_B[MSGSIZE];
	char setgid_A[MSGSIZE], nosetgid_A[MSGSIZE];
	char setgid_B[MSGSIZE], nosetgid_B[MSGSIZE], root_setgid_B[MSGSIZE];
	gid_t group1_gid, group2_gid, mygid;
	uid_t save_myuid, user1_uid;
	pid_t mypid;

	int lc;
	int fail_count = 0;

	tst_parse_opts(ac, av, NULL, NULL);

	setup();

	for (lc = 0; TEST_LOOPING(lc); lc++) {
		local_flag = PASSED;

		save_myuid = getuid();
		mypid = getpid();
		sprintf(DIR_A, DIR_A_TEMP, mypid);
		sprintf(DIR_B, DIR_B_TEMP, mypid);
		sprintf(setgid_A, "%s/%s", DIR_A, SETGID);
		sprintf(nosetgid_A, "%s/%s", DIR_A, NOSETGID);
		sprintf(setgid_B, "%s/%s", DIR_B, SETGID);
		sprintf(nosetgid_B, "%s/%s", DIR_B, NOSETGID);
		sprintf(root_setgid_B, "%s/%s", DIR_B, ROOT_SETGID);

		/* Get the uid of user1 */
		user1 = getpwnam("nobody");
		if (user1 == NULL)
			tst_brkm(TBROK, cleanup, "nobody not in /etc/passwd");

		user1_uid = user1->pw_uid;

		/*
		 * Get the group IDs of group1 and group2.
		 */
		group = getgrnam("nobody");
		if (group == NULL) {
			group = getgrnam("nogroup");
			if (group == NULL) {
				tst_brkm(TBROK, cleanup,
					 "nobody/nogroup not in /etc/group");
			}
		}
		group1_gid = group->gr_gid;
		group = getgrnam("bin");
		if (group == NULL)
			tst_brkm(TBROK, cleanup, "bin not in /etc/group");

		group2_gid = group->gr_gid;

		/*
		 * Create a directory with group id the same as this process
		 * and with no setgid bit.
		 */
		if (mkdir(DIR_A, MODE_RWX) < 0) {
			tst_resm(TFAIL | TERRNO, "mkdir(%s) failed", DIR_A);
			local_flag = FAILED;
		}

		if (chown(DIR_A, user1_uid, group2_gid) < 0) {
			tst_resm(TFAIL | TERRNO, "chown(%s) failed", DIR_A);
			local_flag = FAILED;
		}

		if (stat(DIR_A, &buf) < 0) {
			tst_resm(TFAIL | TERRNO, "stat(%s) failed", DIR_A);
			local_flag = FAILED;
		}

		/* Verify modes */
		if (buf.st_mode & S_ISGID) {
			tst_resm(TFAIL, "%s: Incorrect modes, setgid bit set",
				 DIR_A);
			local_flag = FAILED;
		}

		/* Verify group ID */
		if (buf.st_gid != group2_gid) {
			tst_resm(TFAIL, "%s: Incorrect group (got %d and %d)",
				 DIR_A, buf.st_gid, group2_gid);
			local_flag = FAILED;
		}

		/*
		 * Create a directory with group id different from that of
		 * this process and with the setgid bit set.
		 */
		if (mkdir(DIR_B, MODE_RWX) < 0) {
			tst_resm(TFAIL | TERRNO, "mkdir(%s) failed", DIR_B);
			local_flag = FAILED;
		}

//.........这里部分代码省略.........
开发者ID:1587,项目名称:ltp,代码行数:101,代码来源:open10.c


示例15: main

int
main(int ac, char **av)
{
    int lc;		/* loop counter */
    const char *msg;	/* message returned from parse_opts */
    long tret;
    
    /***************************************************************
     * parse standard options
     ***************************************************************/
    if ( (msg=parse_opts(ac, av, (option_t *) NULL, NULL)) != (char *) NULL ) {
	tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
	tst_exit(0);
    }

    /***************************************************************
     * perform global setup for test
     ***************************************************************/
    setup();

    /***************************************************************
     * check looping state if -c option given
     ***************************************************************/
    for (lc=0; TEST_LOOPING(lc); lc++) {

	/* reset Tst_count in case we are looping. */
	Tst_count=0;

		
	/* 
	 * TEST CASE:
	 * Increase by 8192 bytes
	 */
	Increment = 8192;

	/* Call sbrk(2) */
#if defined(sgi)
	tret=(long)sbrk(Increment);   /* Remove -64 IRIX compiler warning */
	TEST_ERRNO=errno;
#else
	TEST(sbrk(Increment));
	tret=TEST_RETURN;
#endif
	
	/* check return code */
	if ( tret == -1 ) {
	    TEST_ERROR_LOG(TEST_ERRNO);
	    tst_resm(TFAIL, "sbrk - Increase by 8192 bytes 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, "sbrk - Increase by 8192 bytes returned %d", 
		    tret);
	    } 
	}
	
	
	/* 
	 * TEST CASE:
	 * Decrease to original size
	 */
	Increment=(Increment * -1);

	/* Call sbrk(2) */
#ifdef CRAY
	TEST(sbrk(Increment));
	tret=TEST_RETURN;
#else
	tret=(long)sbrk(Increment);
	TEST_ERRNO=errno;
#endif
	
	/* check return code */
	if ( tret == -1 ) {
	    TEST_ERROR_LOG(TEST_ERRNO);
	    tst_resm(TFAIL, "sbrk - Decrease to original size 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, "sbrk - Decrease to original size returned %d", tret);
	    } 
	}
	

    }	/* End for TEST_LOOPING */

    /***************************************************************
     * cleanup and exit
     ***************************************************************/
    cleanup();

    return 0;
//.........这里部分代码省略.........
开发者ID:hallco978,项目名称:msys,代码行数:101,代码来源:sbrk01.c


示例16: setup

  void BitVector_Test::Test_bitVectorSetAndClearBits()
  {
    BitVector<256>* bits;
    bits = setup();

    assertUnchanged(0,7);
    bits->ClearBits(0,64);

    assertUnchanged(2,7);
    assert(bits->Read(0,32) == 0);
    assert(bits->Read(32,32) == 0);

    bits->SetBits(48,64);  // hits 1,2,3
    assert(bits->Read(0,32) == 0);
    assert(bits->Read(32,32) == 0x0000ffff);
    assert(bits->Read(64,32) == 0xffffffff);
    assert(bits->Read(96,32) == 0xffffdef0);

    bits = setup();
    bits->ClearBits(31,33);  // 0,1; unaligned start, aligned end

    assert(bits->Read(0,32) == 0x24681356);
    assert(bits->Read(32,32) == 0x0);
    assertUnchanged(2,7);

    bits = setup();
    bits->ClearBits(128,32+32+32+1);  // 4-7; aligned start, unaligned end

    assertUnchanged(0,3);
    assert(bits->Read(128,32) == 0x0);
    assert(bits->Read(160,32) == 0x0);
    assert(bits->Read(192,32) == 0x0);
    assert(bits->Read(224,32) == 0x7edbca09);

    bits = setup();
    bits->SetBits(128,32+32+32+32);  // 4-6; aligned start, aligned end

    assertUnchanged(0,3);
    assert(bits->Read(128,32) == 0xffffffff);
    assert(bits->Read(160,32) == 0xffffffff);
    assert(bits->Read(192,32) == 0xffffffff);
    assertUnchanged(7,7);

    bits = setup();
    bits->SetBits(100,48);        // 3-4; unaligned start, unaligned end, adjacent

    assertUnchanged(0,2);
    assert(bits->Read( 96,32) == 0x9fffffff);
    assert(bits->Read(128,32) == 0xfffffba9);
    assertUnchanged(5,7);

    bits = setup();
    bits->ClearBits(4,48); // 0-1; unaligned start&end, adjacent, first unit

    assert(bits->Read(  0,32) == 0x20000000);
    assert(bits->Read( 32,32) == 0x00000314);
    assertUnchanged(2,7);

    bits = setup();
    bits->ClearBits(192+16,32); // 6-7; unaligned start&end, adjacent, last unit

    assertUnchanged(0,5);
    assert(bits->Read(192,32) == 0x44330000);
    assert(bits->Read(224,32) == 0x0000ca09);

    bits = setup();
    bits->ClearBits(32+16,32*5); // 1-6; unaligned start&end, non-adjacent

    assertUnchanged(0,0);
    assert(bits->Read( 32,32) == 0x11120000);
    assert(bits->Read( 64,32) == 0x00000000);
    assert(bits->Read( 96,32) == 0x00000000);
    assert(bits->Read(128,32) == 0x00000000);
    assert(bits->Read(160,32) == 0x00000000);
    assert(bits->Read(192,32) == 0x00002211);
    assertUnchanged(7,7);

    bits = setup();
    bits->ClearBits(16,32*7); // 0-7; unaligned start&end, all units

    assert(bits->Read(  0,32) == 0x24680000);
    assert(bits->Read( 32,32) == 0x00000000);
    assert(bits->Read( 64,32) == 0x00000000);
    assert(bits->Read( 96,32) == 0x00000000);
    assert(bits->Read(128,32) == 0x00000000);
    assert(bits->Read(160,32) == 0x00000000);
    assert(bits->Read(192,32) == 0x00000000);
    assert(bits->Read(224,32) == 0x0000ca09);

    bits = setup();
    bits->ClearBits(0,32*8); // 0-7; all bits cleared

    for (u32 i = 0; i < 32*8; i += 32)
      assert(bits->Read(i,32) == 0x00000000);

    bits->SetBits(0,32*8); // 0-7; all bits set

    for (u32 i = 0; i < 32*8; i += 32)
      assert(bits->Read(i,32) == 0xffffffff);
  }
开发者ID:DaveAckley,项目名称:MFM,代码行数:100,代码来源:BitVector_Test.cpp


示例17: main

int main(int ac, char **av) {
        pid_t pid1;
	int lc;                 /* loop counter */
        char *msg;              /* message TEST_RETURNurned from parse_opts */
	
        /* parse standard options */
        if ((msg = parse_opts(ac, av, (option_t *)NULL, NULL)) != (char *)NULL){
             tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
             tst_exit();
           }

        setup();

        /* Check looping state if -i option given */
        for (lc = 0; TEST_LOOPING(lc); ++lc) {
                Tst_count = 0;
                for (testno = 0; testno < TST_TOTAL; ++testno) {

 /*
 *fork a child process;testing which one is a child or a parent;
 * */
		        TEST(pid1=fork());    //call to fork()
			if (TEST_RETURN == -1) {
				tst_resm(TFAIL|TTERRNO, "fork() failed.");
				cleanup();
				tst_exit();
			} else if (TEST_RETURN == 0) {
				TEST_RETURN = unshare(CLONE_FS);
				if (TEST_RETURN == 0)
					tst_resm(TPASS,
						"unshare with CLONE_FILES call "
						"succeeded");
				else if (TEST_RETURN == -1) {
					if (errno == ENOSYS)
						tst_resm(TCONF,
							"unshare is not "
							"implemented in kernel."
							);
					else
						tst_resm(TFAIL|TERRNO,
							"unshare failed.");
				}
				tst_exit();
			}else{
			}

			TEST(pid1=fork());    //call to fork()
			if (TEST_RETURN == -1) {
				tst_resm(TFAIL|TTERRNO, "fork() failed.");
	                        cleanup();
                        	tst_exit();
			} else if (TEST_RETURN == 0) {
				TEST_RETURN = unshare(CLONE_FS);
				if (TEST_RETURN == 0)
					tst_resm(TPASS,
						"unshare with CLONE_FS call "
						"succeeded");
				else if (TEST_RETURN == -1) {
					if (errno == ENOSYS)
						tst_resm(TCONF,
							"unshare is not "
							"implemented in kernel."
							);
					else
						tst_resm(TFAIL|TERRNO,
							"unshare failed 2.");
				}
				tst_exit();
                        }else{
			}

			TEST(pid1=fork());    //call to fork()
			if (TEST_RETURN == -1) {
				tst_resm(TFAIL|TTERRNO, "fork() failed.");
	                        cleanup();
                        	tst_exit();
			} else if (TEST_RETURN == 0) {
				TEST_RETURN = unshare(CLONE_NEWNS);
				if (TEST_RETURN == 0) {
					tst_resm(TPASS,
						"unshare call with CLONE_NEWNS "
						"succeeded");
				} else if (TEST_RETURN == -1) {
					if (errno == ENOSYS)
						tst_resm(TCONF,
							"unshare is not "
							"implemented in kernel."
							);
					else
						tst_resm(TFAIL|TERRNO,
							"unshare failed 2.");
				}
				tst_exit();
                        }else{
			}


                }

                }
//.........这里部分代码省略.........
开发者ID:ystk,项目名称:debian-ltp,代码行数:101,代码来源:unshare01.c


示例18: test_setup

int test_setup() {
    setup();
}
开发者ID:jwbowler,项目名称:maslab-staff-2013,代码行数:3,代码来源:fpstest2.cpp


示例19: initialize

/* MotionManager::MotionManager: constructor */
MotionManager::MotionManager(PMDModel * pmd)
{
    initialize();
    setup(pmd);
}
开发者ID:ljmljz,项目名称:MMDAgent,代码行数:6,代码来源:MotionManager.cpp


示例20: test_position_targets_suite__040

// Pawn attacks.
void test_position_targets_suite__040(void) {
	setup("Ke1,a3,b3,c3,d3,e3,f3,g3,h3", "Ke8,a6,b6,c6,d6,e6,f6,g6,h6");
    	Position *p = start();
	cl_check(pawn_attacks(p, White) == (bit[A4] | bit[B4] | bit[C4] | bit[D4] | bit[E4] | bit[F4] | bit[G4] | bit[H4]));
	cl_check(pawn_attacks(p, Black) == (bit[A5] | bit[B5] | bit[C5] | bit[D5] | bit[E5] | bit[F5] | bit[G5] | bit[H5]));
}
开发者ID:michaeldv,项目名称:donna_vista,代码行数:7,代码来源:position_targets_suite.c



注:本文中的setup函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ setupActions函数代码示例发布时间:2022-05-30
下一篇:
C++ setuid函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap