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

C++ pass函数代码示例

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

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



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

示例1: pass

void BytecodeGeneratorification::run()
{
    // We calculate the liveness at each merge point. This gives us the information which registers should be saved and resumed conservatively.

    {
        GeneratorLivenessAnalysis pass(*this);
        pass.run();
    }

    UnlinkedCodeBlock* codeBlock = m_graph.codeBlock();
    BytecodeRewriter rewriter(m_graph);

    // Setup the global switch for the generator.
    {
        unsigned nextToEnterPoint = enterPoint() + opcodeLength(op_enter);
        unsigned switchTableIndex = m_graph.codeBlock()->numberOfSwitchJumpTables();
        VirtualRegister state = virtualRegisterForArgument(static_cast<int32_t>(JSGeneratorFunction::GeneratorArgument::State));
        auto& jumpTable = m_graph.codeBlock()->addSwitchJumpTable();
        jumpTable.min = 0;
        jumpTable.branchOffsets.resize(m_yields.size() + 1);
        jumpTable.branchOffsets.fill(0);
        jumpTable.add(0, nextToEnterPoint);
        for (unsigned i = 0; i < m_yields.size(); ++i)
            jumpTable.add(i + 1, m_yields[i].point);

        rewriter.insertFragmentBefore(nextToEnterPoint, [&](BytecodeRewriter::Fragment& fragment) {
            fragment.appendInstruction(op_switch_imm, switchTableIndex, nextToEnterPoint, state.offset());
        });
    }

    for (const YieldData& data : m_yields) {
        VirtualRegister scope = virtualRegisterForArgument(static_cast<int32_t>(JSGeneratorFunction::GeneratorArgument::Frame));

        // Emit save sequence.
        rewriter.insertFragmentBefore(data.point, [&](BytecodeRewriter::Fragment& fragment) {
            data.liveness.forEachSetBit([&](size_t index) {
                VirtualRegister operand = virtualRegisterForLocal(index);
                Storage storage = storageForGeneratorLocal(index);

                fragment.appendInstruction(
                    op_put_to_scope,
                    scope.offset(), // scope
                    storage.identifierIndex, // identifier
                    operand.offset(), // value
                    GetPutInfo(DoNotThrowIfNotFound, LocalClosureVar, InitializationMode::NotInitialization).operand(), // info
                    m_generatorFrameSymbolTableIndex, // symbol table constant index
                    storage.scopeOffset.offset() // scope offset
                );
            });

            // Insert op_ret just after save sequence.
            fragment.appendInstruction(op_ret, data.argument);
        });

        // Emit resume sequence.
        rewriter.insertFragmentAfter(data.point, [&](BytecodeRewriter::Fragment& fragment) {
            data.liveness.forEachSetBit([&](size_t index) {
                VirtualRegister operand = virtualRegisterForLocal(index);
                Storage storage = storageForGeneratorLocal(index);

                UnlinkedValueProfile profile = codeBlock->addValueProfile();
                fragment.appendInstruction(
                    op_get_from_scope,
                    operand.offset(), // dst
                    scope.offset(), // scope
                    storage.identifierIndex, // identifier
                    GetPutInfo(DoNotThrowIfNotFound, LocalClosureVar, InitializationMode::NotInitialization).operand(), // info
                    0, // local scope depth
                    storage.scopeOffset.offset(), // scope offset
                    profile // profile
                );
            });
        });

        // Clip the unnecessary bytecodes.
        rewriter.removeBytecode(data.point);
    }

    rewriter.execute();
}
开发者ID:endlessm,项目名称:WebKit,代码行数:80,代码来源:BytecodeGeneratorification.cpp


示例2: main

int main(int argc, char **argv)
{
	int ret = -1, fd, status;
	char path[PATH_MAX];
	pid_t pid;

	if (!getenv("ZDTM_NEWNS")) {
		if (mount_and_add(cgname, "test") < 0)
			return -1;

		if (unshare(CLONE_NEWCGROUP) < 0) {
			pr_perror("unshare");
			goto out;
		}
	}

	test_init(argc, argv);

	test_daemon();
	test_waitsig();

	sprintf(path, "name=%s", cgname);

	/* first check that the task is in zdtmtst:/ */
	if (!pid_in_cgroup(getpid(), path, "/")) {
		fail("pid not in cgroup /");
		goto out;
	}

	/* now check that the task is in the right place in a ns by setnsing to
	 * someone else's ns and looking there.
	 */
	pid = fork();
	if (pid < 0) {
		pr_perror("fork");
		goto out;
	}

	if (pid == 0) {
		sprintf(path, "/proc/%d/ns/cgroup", 1);
		fd = open(path, O_RDONLY);
		if (fd < 0) {
			pr_perror("open");
			exit(1);
		}

		ret = setns(fd, CLONE_NEWCGROUP);
		close(fd);
		if (ret < 0) {
			pr_perror("setns");
			exit(1);
		}

		sprintf(path, "name=%s", cgname);
		if (!pid_in_cgroup(getppid(), path, "/test")) {
			fail("pid not in cgroup %s", path);
			exit(1);
		}

		exit(0);
	}

	if (pid != waitpid(pid, &status, 0)) {
		pr_err("wrong pid");
		goto out;
	}

	if (!WIFEXITED(status) || WEXITSTATUS(status)) {
		pr_err("got bad exit status %d\n", status);
		goto out;
	}

	ret = 0;
	pass();

out:
	sprintf(path, "%s/%s/test", dirname, cgname);
	rmdir(path);
	sprintf(path, "%s/%s", dirname, cgname);
	umount(path);
	rmdir(path);
	rmdir(dirname);
	return ret;
}
开发者ID:0x7f454c46,项目名称:criu-1,代码行数:84,代码来源:cgroupns.c


示例3: main

int main(void) {
 run_test(test);
 pass();
 return 0;
}
开发者ID:Ravenbrook,项目名称:mps,代码行数:5,代码来源:163.c


示例4: main

int main(int argc, char**argv) {
  int err=0;
  err+=test_defaultmatrix("FuMa[f]" , 4, 4, AMBIX_MATRIX_FUMA    , 3, 1024, 6e-8);
  return pass();
}
开发者ID:iem-projects,项目名称:ambix,代码行数:5,代码来源:basic2extended_FUMA4x4_3extra_float64.c


示例5: main

int main(int argc, char**argv) {
  check_create_extended("test2-pcm32.caf",  AMBIX_SAMPLEFORMAT_PCM32, 1024, 1e-5);

  pass();
  return 0;
}
开发者ID:OpenDAWN,项目名称:libambix,代码行数:6,代码来源:extended_pcm32_1024.c


示例6: main


//.........这里部分代码省略.........
		goto failed;
	}

	if (unlink(filename) < 0) {
		pr_perror("can't unlink %s", filename);
		goto failed;
	}
	/* Change file size */
	if (fst.st_size != 0) {
		pr_perror("%s file size eq %d", fst.st_size);
		goto failed;
	}

	crc = ~0;
	datagen(buf, sizeof(buf), &crc);
	if (write(fd, buf, sizeof(buf)) != sizeof(buf)) {
		pr_perror("can't write %s", filename);
		goto failed;
	}
	/* Change file mode */
	if ((fst.st_mode & S_IXOTH) == 0)
		mode = (fst.st_mode | S_IXOTH);
	else
		mode = (fst.st_mode ^ S_IXOTH);

	if (fchmod(fd, mode) < 0) {
		pr_perror("can't chmod %s", filename);
		goto failed;
	}

	if (getuid()) {
		uid = getuid();
		gid = getgid();
	} else {
		/* Change uid, gid */
		if (fchown(fd, (uid = fst.st_uid + 1), (gid = fst.st_gid + 1)) < 0) {
			pr_perror("can't chown %s", filename);
			goto failed;
		}
	}

	if (lseek(fd, 0, SEEK_SET) != 0) {
		pr_perror("can't reposition to 0");
		goto failed;
	}

	test_daemon();
	test_waitsig();

	if (fstat(fd, &fst) < 0) {
		pr_perror("can't get %s file info after", filename);
		goto failed;
	}

	/* Check file size */
	if (fst.st_size != fsize) {
		fail("(via fstat): file size changed to %d", fst.st_size);
		goto failed;
	}
	fst.st_size = lseek(fd, 0, SEEK_END);
	if (fst.st_size != fsize) {
		fail("(via lseek): file size changed to %d", fst.st_size);
		goto failed;
	}
	/* Check mode */
	if (fst.st_mode != mode) {
		fail("mode is changed to %o(%o)", fst.st_mode, mode);
		goto failed;
	}
	/* Check uid, gid */
	if (fst.st_uid != uid || fst.st_gid != gid) {
		fail("u(g)id changed: uid=%d(%d), gid=%d(%d)",
				fst.st_uid, uid, fst.st_gid, gid);
		goto failed;
	}

	if (lseek(fd, 0, SEEK_SET) != 0) {
		pr_perror("can't reposition to 0");
		goto failed;
	}
	if (read(fd, buf, sizeof(buf)) != sizeof(buf)) {
		fail("can't read %s: %m\n", filename);
		goto failed;
	}

	crc = ~0;
	if (datachk(buf, sizeof(buf), &crc)) {
		fail("CRC mismatch\n");
		goto failed;
	}

	close(fd);

	pass();
	return 0;
failed:
	unlink(filename);
	close(fd);
	return 1;
}
开发者ID:0x7f454c46,项目名称:criu-1,代码行数:101,代码来源:unlink_fstat00.c


示例7: main

int main(int argc, char **argv)
{
	int cgfd, l, ret = 1, i;
	char aux[1024], paux[1024];
	FILE *cgf;
	struct stat st;

	test_init(argc, argv);

	if (mkdir(dirname, 0700) < 0) {
		err("Can't make dir");
		goto out;
	}

	sprintf(aux, "none,name=%s", cgname);
	if (mount("none", dirname, "cgroup", 0, aux)) {
		err("Can't mount cgroups");
		goto out_rd;
	}

	sprintf(paux, "%s/%s", dirname, subname);
	mkdir(paux, 0600);

	l = sprintf(aux, "%d", getpid());
	sprintf(paux, "%s/%s/tasks", dirname, subname);

	cgfd = open(paux, O_WRONLY);
	if (cgfd < 0) {
		err("Can't open tasks");
		goto out_rs;
	}

	l = write(cgfd, aux, l);
	close(cgfd);

	if (l < 0) {
		err("Can't move self to subcg");
		goto out_rs;
	}

	for (i = 0; i < 2; i++) {
		sprintf(paux, "%s/%s/%s.%d", dirname, subname, empty, i);
		if (mkdir(paux, 0600)) {
			err("mkdir %s", paux);
			return 1;
		}
	}

	test_daemon();
	test_waitsig();

	cgf = fopen("/proc/self/mountinfo", "r");
	if (cgf == NULL) {
		fail("No mountinfo file");
		goto out_rs;
	}

	while (fgets(paux, sizeof(paux), cgf)) {
		char *s;

		s = strstr(paux, cgname);
		if (!s)
			continue;

		sscanf(paux, "%*d %*d %*d:%*d %*s %s", aux);
		test_msg("found cgroup at %s\n", aux);

		for (i = 0; i < 2; i++) {
			sprintf(paux, "%s/%s/%s.%d", aux, subname, empty, i);
			if (stat(paux, &st)) {
				fail("couldn't stat %s\n", paux);
				ret = -1;
				goto out_close;
			}

			if (!S_ISDIR(st.st_mode)) {
				fail("%s is not a directory\n", paux);
				ret = -1;
				goto out_close;
			}
		}

		pass();
		ret = 0;
		goto out_close;
	}

	fail("empty cgroup not found!\n");

out_close:
	fclose(cgf);
out_rs:
	umount(dirname);
out_rd:
	rmdir(dirname);
out:
	return ret;
}
开发者ID:balamark,项目名称:criu,代码行数:98,代码来源:cgroup01.c


示例8: main


//.........这里部分代码省略.........
		kill(0, SIGKILL);
		exit(1);
	}
	if (pid == 0) {
		file_path = path[0];
		readfd = open(file_path, O_RDONLY);
		if (readfd < 0) {
			err("open(%s, O_RDONLY) Failed: %m\n", file_path);
			ret = errno;
			return ret;
		}
		file_path = path[1];
		writefd = open(file_path, O_WRONLY);
		if (writefd < 0) {
			err("open(%s, O_WRONLY) Failed: %m\n", file_path);
			ret = errno;
			return ret;
		}

		if (pipe_in2out(readfd, writefd, buf, sizeof(buf)) < 0)
			/* pass errno as exit code to the parent */
			if (test_go() /* signal NOT delivered */ ||
					(errno != EINTR && errno != EPIPE))
				ret = errno;
		close(readfd);
		close(writefd);
		exit(ret);
	}
	file_path = path[0];
	writefd = open(file_path, O_WRONLY);
	if (writefd < 0) {
		err("open(%s, O_WRONLY) Failed: %m\n", file_path);
		kill(pid, SIGKILL);
		return 1;
	}

	file_path = path[1];
	readfd = open(file_path, O_RDONLY);
	if (readfd < 0) {
		err("open(%s, O_RDONLY) Failed: %m\n", file_path);
		kill(pid, SIGKILL);
		return 1;
	}
	test_daemon();

	while (test_go()) {
		int len, rlen = 0, wlen;
		uint8_t rbuf[sizeof(buf)], *p;

		datagen(buf, sizeof(buf), NULL);
		wlen = write(writefd, buf, sizeof(buf));
		if (wlen < 0) {
			if (errno == EINTR)
				continue;
			else {
				fail("write failed: %m\n");
				ret = 1;
				break;
			}
		}

		for (p = rbuf, len = wlen; len > 0; p += rlen, len -= rlen) {
			rlen = read(readfd, p, len);
			if (rlen <= 0)
				break;
		}

		if (rlen < 0 && errno == EINTR)
			continue;

		if (len > 0) {
			fail("read failed: %m\n");
			ret = 1;
			break;
		}

		if (memcmp(buf, rbuf, wlen)) {
			fail("data mismatch\n");
			ret = 1;
			break;
		}
	}

	close(writefd);
	test_waitsig();

	wait(&chret);
	chret = WEXITSTATUS(chret);
	if (chret) {
		fail("child exited with non-zero code %d (%s)\n",
			chret, strerror(chret));
		return 1;
	}
	if (!ret)
		pass();
	close(readfd);
	for (i = 0; i < PROCS_DEF; i++)
		unlink(path[i]);
	return 0;
}
开发者ID:OSLL,项目名称:pmover,代码行数:101,代码来源:fifo_dyn.c


示例9: get

	glm::vec4 get( int i )
	{
		return pass(i) ? window[i] : glm::vec4(0,0,0,1);
	}
开发者ID:shammellee,项目名称:moon9,代码行数:4,代码来源:viewport.cpp


示例10: run

            void run() {
//                log() << "******** NOT RUNNING TruncateCapped test yet ************" << endl;
                pass(0);
            }
开发者ID:vigneshncc,项目名称:mongo,代码行数:4,代码来源:namespacetests.cpp


示例11: main

int main(int argc, char **argv)
{
	struct sockaddr_un addr;
	unsigned int addrlen;
	int srv, clnt = -1, ret, i;
	char buf[1024];
	struct iovec iov = {
			.iov_base = &buf,
			.iov_len = sizeof(buf),
		};
	struct msghdr hdr = {
			.msg_name = &addr,
			.msg_namelen = sizeof(addr),
			.msg_iov = &iov,
			.msg_iovlen = 1,
		};

	test_init(argc, argv);

	srv = socket(PF_UNIX, SOCK_DGRAM | SOCK_NONBLOCK, 0);

	addr.sun_family = AF_UNIX;
	memcpy(addr.sun_path, SK_SRV, sizeof(SK_SRV));
	addrlen = sizeof(addr.sun_family) + sizeof(SK_SRV);

	if (bind(srv, &addr, addrlen)) {
		fail("bind\n");
		exit(1);
	}

	for (i = 0; i < 2; i++) {
		close(clnt);
		clnt = socket(PF_UNIX, SOCK_DGRAM | SOCK_NONBLOCK, 0);

		sk_names[i][1] += i;
		addr.sun_family = AF_UNIX;
		memcpy(addr.sun_path, sk_names[i], sizeof(SK_NAME));
		addrlen = sizeof(addr.sun_family) + sizeof(SK_NAME);

		if (bind(clnt, &addr, addrlen)) {
			fail("bind\n");
			exit(1);
		}

		memcpy(addr.sun_path, SK_SRV, sizeof(SK_SRV));
		addrlen = sizeof(addr.sun_family) + sizeof(SK_SRV);
		if (connect(clnt, &addr, addrlen)) {
			fail("connect\n");
			exit(1);
		}

		if (send(clnt, MSG, sizeof(MSG), 0) != sizeof(MSG)) {
			pr_perror("write");
			return 1;
		}
	}

	test_daemon();
	test_waitsig();

	for (i = 0; i < 2; i++) {
		memset(addr.sun_path, 0, sizeof(addr.sun_path));
		ret = recvmsg(srv, &hdr, MSG_DONTWAIT);
		buf[ret > 0 ? ret : 0] = 0;
		if (ret != sizeof(MSG)) {
			fail("%d: %s", ret, buf);
			return 1;
		}
		if (hdr.msg_namelen > sizeof(addr.sun_family) + 1)
			pr_perror("%d, %s", hdr.msg_namelen, addr.sun_path + 1);
		if (memcmp(addr.sun_path, sk_names[i], sizeof(SK_NAME))) {
			fail("A sender address is mismatch");
			return 1;
		}
	}

	pass();
	return 0;
}
开发者ID:0x7f454c46,项目名称:criu-1,代码行数:79,代码来源:socket_snd_addr.c


示例12: main

int main(int argc, char ** argv)
{
	int pipe1[2];
	int pipe2[2];
	int ret;
	pid_t pid;
	char buf[sizeof(TEST_STRING)];

	test_init(argc, argv);

	ret = pipe(pipe1);
	if (ret)
		return 1;

	ret = pipe(pipe2);
	if (ret)
		return 1;

	pid = test_fork();
	if (pid < 0) {
		err("Can't fork");
		exit(1);
	} else if (pid == 0) {
		if (dup2(pipe1[1], 11) == -1 || dup2(pipe2[0], 12) == -1) {
			err("dup2 failed");
			return 1;
		}
	} else {
		if (dup2(pipe1[0], 12) == -1 ||	dup2(pipe2[1], 11) == -1) {
			err("dup2 failed");
			goto err;
		}
	}

	close(pipe2[0]);
	close(pipe2[1]);
	close(pipe1[0]);
	close(pipe1[1]);

	if (pid > 0) {
		int status;

		test_daemon();

		test_waitsig();

		ret = read(12, buf, sizeof(TEST_STRING));
		if (ret != sizeof(TEST_STRING)) {
			err("read failed: %d", ret);
			goto err;
		}
		ret = write(11, TEST_STRING, sizeof(TEST_STRING));
		if (ret != sizeof(TEST_STRING)) {
			err("write failed: %d", ret);
			goto err;
		}
		close(11);
		ret = read(12, buf, sizeof(TEST_STRING));
		if (ret != sizeof(TEST_STRING)) {
			err("read failed: %d", ret);
			goto err;
		}
		if (strcmp(TEST_STRING, buf)) {
			err("data curruption");
			goto err;
		}

		ret = wait(&status);
		if (ret == -1 || !WIFEXITED(status) || WEXITSTATUS(status)) {
			kill(pid, SIGKILL);
			goto err;
		}

		pass();
	} else {
		ret = write(11, TEST_STRING, sizeof(TEST_STRING));
		if (ret != sizeof(TEST_STRING)) {
			err("write failed: %d", ret);
			return 1;
		}
		ret = read(12, buf, sizeof(TEST_STRING));
		if (ret != sizeof(TEST_STRING)) {
			err("read failed: %d", ret);
			return 1;
		}
		ret = write(11, TEST_STRING, sizeof(TEST_STRING));
		if (ret != sizeof(TEST_STRING)) {
			err("write failed: %d", ret);
			return 1;
		}
		close(11);
		if (strcmp(TEST_STRING, buf)) {
			err("data curruption");
			return 1;
		}
	}

	return 0;
err:
	err("FAIL");
//.........这里部分代码省略.........
开发者ID:avagin,项目名称:crtools,代码行数:101,代码来源:pipe00.c


示例13: main


//.........这里部分代码省略.........
		count = rand32() % MAX_CHARS_PER_TRIAL + 1;
		
		for (i = 0; i < count; i++) {
			if (o >= oe) {
				fail("utf8_write_char: Buffer overflow (1)");
				goto next_trial;
			}
			
			switch (rand32() % 7) {
				case 0:
					c = range(rand32(), 0x0, 0x7F);
					c_valid = true;
					break;
				case 1:
					c = range(rand32(), 0x80, 0x7FF);
					c_valid = true;
					break;
				case 2:
					c = range(rand32(), 0x800, 0xD7FF);
					c_valid = true;
					break;
				case 3:
					c = range(rand32(), 0xD800, 0xDFFF);
					c_valid = false;
					break;
				case 4:
					c = range(rand32(), 0xE000, 0xFFFF);
					c_valid = true;
					break;
				case 5:
					c = range(rand32(), 0x10000, 0x10FFFF);
					c_valid = true;
					break;
				default:
					do {
						c = rand32();
					} while (c < 0x110000);
					c_valid = false;
					break;
			}
			
			codepoints[i] = c_valid ? c : REPLACEMENT_CHARACTER;
			
			len = utf8_write_char(c, o);
			if (len < 1 || len > 4) {
				fail("utf8_write_char: Return value is not 1 thru 4.");
				goto next_trial;
			}
			o += len;
		}
		if (o > oe) {
			fail("utf8_write_char: Buffer overflow (2)");
			goto next_trial;
		}
		
		string = malloc(o - write_buffer);
		memcpy(string, write_buffer, o - write_buffer);
		s = string;
		e = string + (o - write_buffer);
		
		if (!utf8_validate(s, e - s)) {
			fail("Invalid string produced by utf8_write_char.");
			goto next_trial_free_string;
		}
		
		for (i = 0; i < count; i++) {
			if (s >= e) {
				fail("utf8_read_char: Buffer overflow (1)");
				goto next_trial_free_string;
			}
			
			len = utf8_read_char(s, &c);
			if (len < 1 || len > 4) {
				fail("utf8_read_char: Return value is not 1 thru 4.");
				goto next_trial_free_string;
			}
			if (c != codepoints[i]) {
				fail("utf8_read_char: Character read differs from that written.");
				goto next_trial_free_string;
			}
			s += len;
		}
		if (s > e) {
			fail("utf8_read_char: Buffer overflow (2)");
			goto next_trial_free_string;
		}
		if (s < e) {
			fail("utf8_read_char: Did not reach end of string.");
			goto next_trial_free_string;
		}
		
		pass("Trial %d: %d characters", trial, count);
		
	next_trial_free_string:
		free(string);
	next_trial:;
	}
	
	return exit_status();
}
开发者ID:GarysRefererence2014,项目名称:ccan,代码行数:101,代码来源:run-utf8-read-write.c


示例14: performGeneratorification

void performGeneratorification(UnlinkedCodeBlock* codeBlock, UnlinkedCodeBlock::UnpackedInstructions& instructions, SymbolTable* generatorFrameSymbolTable, int generatorFrameSymbolTableIndex)
{
    BytecodeGeneratorification pass(codeBlock, instructions, generatorFrameSymbolTable, generatorFrameSymbolTableIndex);
    pass.run();
}
开发者ID:endlessm,项目名称:WebKit,代码行数:5,代码来源:BytecodeGeneratorification.cpp


示例15: main

int main(int argc, char **argv)
{
	char path[PATH_MAX], bpath[PATH_MAX], spath[PATH_MAX], bspath[PATH_MAX];
	pid_t pid;
	int status;
	task_waiter_t t;

	test_init(argc, argv);

	task_waiter_init(&t);

	mount(NULL, "/", NULL, MS_SHARED, NULL);

	snprintf(path, sizeof(path), "%s/test", dirname);
	snprintf(bpath, sizeof(bpath), "%s/test.bind", dirname);
	snprintf(spath, sizeof(spath), "%s/test/sub", dirname);
	snprintf(bspath, sizeof(bspath), "%s/test.bind/sub", dirname);

	if (mkdir(dirname, 0700) ||
	    mkdir(path, 0700) ||
	    mkdir(spath, 0700) ||
	    mkdir(bpath, 0700)) {
		err("mkdir");
		return 1;
	}

	pid = fork();
	if (pid < 0) {
		err("fork");
		return 1;
	}
	if (pid == 0) {
		unshare(CLONE_NEWNS);
		if (mount(path, bpath, NULL, MS_BIND, NULL)) {
			err("mount");
			return 1;
		}

		task_waiter_complete(&t, 1);
		task_waiter_wait4(&t, 2);

		if (access(bspath, F_OK)) {
			fail("%s isn't accessiable", bspath);
			return 1;
		}


		if (umount2(bpath, MNT_DETACH)) {
			fail("umount");
			return 1;
		}

		return 0;
	}

	task_waiter_wait4(&t, 1);

	if (mount("test", spath, "tmpfs", 0, NULL)) {
		err("mount");
		return 1;
	}

	test_daemon();
	test_waitsig();

	task_waiter_complete(&t, 2);

	if (waitpid(pid, &status, 0) != pid) {
		err("waitpid %d", pid);
		return 1;
	}

	if (status) {
		err("%d/%d/%d/%d", WIFEXITED(status), WEXITSTATUS(status), WIFSIGNALED(status), WTERMSIG(status));
		return 1;
	}

	pass();

	return 0;
}
开发者ID:balamark,项目名称:criu,代码行数:81,代码来源:mntns_root_bind.c


示例16: pass

 bool pass()
 {
    return pass( 0 );
 }
开发者ID:shammellee,项目名称:moon9,代码行数:4,代码来源:viewport.cpp


示例17: main

int main(int argc, char *argv[])
{
    int        p[2];
    int        stdoutfd;
        struct obj exp;

        (void)argc;
        (void)argv;

    printf("1..1\n");
    fflush(stdout);
    stderrfd = dup(STDERR_FILENO);

    if (stderrfd < 0)
        err(1, "dup of stderr failed");

    stdoutfd = dup(STDOUT_FILENO);

    if (stdoutfd < 0)
        err(1, "dup of stdout failed");

    if (pipe(p) != 0)
        failmsg("pipe failed");

    if (dup2(p[1], STDERR_FILENO) < 0 || dup2(p[1], STDOUT_FILENO) < 0)
        failmsg("Duplicating file descriptor");

    plan_tests(10);
    expect(p[0], "1..10\n");

    ok(1, "msg1");
    expect(p[0], "ok 1 - msg1\n");

    ok(0, "msg2");
    expect(p[0], "not ok 2 - msg2\n"
           "#     Failed test (*tap/test/run.c:main() at line 199)\n");

    ok1(true);
    expect(p[0], "ok 3 - true\n");

    ok1(false);
    expect(p[0], "not ok 4 - false\n"
           "#     Failed test (*tap/test/run.c:main() at line 206)\n");

    pass("passed");
    expect(p[0], "ok 5 - passed\n");

    fail("failed");
    expect(p[0], "not ok 6 - failed\n"
           "#     Failed test (*tap/test/run.c:main() at line 213)\n");

    skip(2, "skipping %s", "test");
    expect(p[0], "ok 7 # skip skipping test\n"
           "ok 8 # skip skipping test\n");

    todo_start("todo");
    ok1(false);
    expect(p[0], "not ok 9 - false # TODO todo\n"
                 "#     Failed (TODO) test (*tap/test/run.c:main() at line 222)\n");
    ok1(true);
    expect(p[0], "ok 10 - true # TODO todo\n");
    todo_end();

    if (exit_status() != 3)
        failmsg("Expected exit status 3, not %i", exit_status());

        is(one_int(), 1, "one_int() returns 1");
        expect(p[0], "ok 11 - one_int() returns 1\n");
        is(one_int(), 2, "one_int() returns 2");
        expect(p[0], "not ok 12 - one_int() returns 2\n"
               "#     Failed test (*tap/test/run.c:main() at line 234)\n"
               "#          got: 1\n"
               "#     expected: 2\n");

        is_eq(one_str(), "one", "one_str() returns 'one'");
        expect(p[0], "ok 13 - one_str() returns 'one'\n");
        is_eq(one_str(), "two", "one_str() returns 'two'");
        expect(p[0], "not ok 14 - one_str() returns 'two'\n"
               "#     Failed test (*tap/test/run.c:main() at line 242)\n"
               "#          got: \"one\"\n"
               "#     expected: \"two\"\n");

        exp.id = 1;
        is_cmp(one_obj(), &exp, obj_cmp, obj_to_str, "one_obj() has id 1");
        expect(p[0], "ok 15 - one_obj() has id 1\n");
        exp.id = 2;
        is_cmp(one_obj(), &exp, obj_cmp, obj_to_str, "one_obj() has id 2");
        expect(p[0], "not ok 16 - one_obj() has id 2\n"
               "#     Failed test (*tap/test/run.c:main() at line 252)\n"
               "#          got: {id=1}\n"
               "#     expected: {id=2}\n");

        is_strstr(one_str(), "n", "one_str() contains 'n'");
        expect(p[0], "ok 17 - one_str() contains 'n'\n");
        is_strstr(one_str(), "w", "one_str() contains 'w'");
        expect(p[0], "not ok 18 - one_str() contains 'w'\n"
               "#     Failed test (*tap/test/run.c:main() at line 260)\n"
               "#                     got: \"one\"\n"
               "#     expected to contain: \"w\"\n");
#if 0
//.........这里部分代码省略.........
开发者ID:LucasSiba,项目名称:bits-and-pieces,代码行数:101,代码来源:run.c


示例18: main


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

    sock = setup_srv_sock();
    if (sock < 0)
        exit(1);

    pid = test_fork();
    if (pid < 0) {
        pr_perror("can't fork");
        exit(1);
    }

    if (pid == 0) {	/* child writes to the unlinked socket and returns */
        close(sock);

        sock = setup_clnt_sock();
        if (sock < 0)
            _exit(1);

        test_waitsig();

        crc = ~0;
        datagen(buf, sizeof(buf), &crc);
        if (write(sock, buf, sizeof(buf)) != sizeof(buf)) {
            pr_perror("can't write to socket");
            exit(errno);
        }

        close(sock);
        exit(0);
    }

    acc_sock = accept(sock, NULL, NULL);
    if (acc_sock < 0) {
        pr_perror("can't accept() the connection on \"%s\"", filename);
        goto out_kill;
    }

    close(sock);
    sock = acc_sock;

    if (unlink(filename)) {
        pr_perror("can't unlink %s", filename);
        goto out_kill;
    }

    test_daemon();
    test_waitsig();

    if (kill(pid, SIGTERM)) {
        fail("terminating the child failed: %m\n");
        goto out;
    }

    if (wait(&ret) != pid) {
        fail("wait() returned wrong pid %d: %m\n", pid);
        goto out;
    }

    if (WIFEXITED(ret)) {
        ret = WEXITSTATUS(ret);
        if (ret) {
            fail("child exited with nonzero code %d (%s)\n", ret, strerror(ret));
            goto out;
        }
    }
    if (WIFSIGNALED(ret)) {
        fail("child exited on unexpected signal %d\n", WTERMSIG(ret));
        goto out;
    }

    if (read(sock, buf, sizeof(buf)) != sizeof(buf)) {
        fail("can't read %s: %m\n", filename);
        goto out;
    }

    crc = ~0;
    if (datachk(buf, sizeof(buf), &crc)) {
        fail("CRC mismatch\n");
        goto out;
    }


    if (close(sock)) {
        fail("close failed: %m\n");
        goto out;
    }

    if (unlink(filename) != -1 || errno != ENOENT) {
        fail("file %s should have been deleted before migration: unlink: %m\n", filename);
        goto out;
    }

    pass();

out_kill:
    kill(pid, SIGTERM);
out:
    close(sock);
    return 0;
}
开发者ID:eabatalov,项目名称:criu,代码行数:101,代码来源:deleted_unix_sock.c


示例19: main

int main(int argc, char **argv)
{
	int fd, fd_s, clt;
	char cmd[4096], buf[10];

	test_init(argc, argv);
	signal(SIGPIPE, SIG_IGN);

	if ((fd_s = tcp_init_server(ZDTM_SRV_FAMILY, &port)) < 0) {
		pr_err("initializing server failed\n");
		return 1;
	}


	clt = tcp_init_client(ZDTM_FAMILY, "localhost", port);
	if (clt < 0) {
		pr_perror("Unable to create a client socket");
	        return 1;
	}

	/*
	* parent is server of TCP connection
	*/
	fd = tcp_accept_server(fd_s);
	if (fd < 0) {
		pr_err("can't accept client connection\n");
		return 1;
	}
	if (write(clt, "asd", 3) != 3) {
		pr_perror("Unable to write into a socket");
		return 1;
	}
	snprintf(cmd, sizeof(cmd), "iptables -w -t filter --protocol tcp -A INPUT --dport %d -j REJECT --reject-with tcp-reset", port);
	if (system(cmd))
		return 1;

	if (write(fd, "asdas", 5) == -1) {
		pr_perror("Unable to write into a socket");
		return 1;
	}

	snprintf(cmd, sizeof(cmd), "iptables -w -t filter --protocol tcp -D INPUT --dport %d -j REJECT --reject-with tcp-reset", port);
	if (system(cmd))
		return 1;

	test_daemon();
	test_waitsig();

	if (read(fd, buf, sizeof(buf)) != 3) {
		fail("Unable to read data from a socket");
		return 1;
	}

	if (write(fd, buf, 3) != -1) {
		fail("Can write into a closed socket");
		return 1;
	}

	pass();
	return 0;
}
开发者ID:xemul,项目名称:criu,代码行数:61,代码来源:socket-tcp-reseted.c


示例20: test_fn

static int test_fn(int argc, char **argv)
{
	FILE *f;
	int fd, tmpfs_fd;
	unsigned fs_cnt, fs_cnt_last = 0;

again:
	fs_cnt = 0;
	f = fopen("/proc/self/mountinfo", "r");
	if (!f) {
		fail("Can't open mountinfo");
		return -1;
	}

	while (fgets(buf, sizeof(buf), f) != NULL) {
		char *mp = buf, *end;

		mp = strchr(mp, ' ') + 1;
		mp = strchr(mp, ' ') + 1;
		mp = strchr(mp, ' ') + 1;
		mp = strchr(mp, ' ') + 1;
		end = strchr(mp, ' ');
		*end = '\0';

		if (!strcmp(mp, "/"))
			continue;
		if (!strcmp(mp, "/proc"))
			continue;

		umount(mp);
		fs_cnt++;
	}

	fclose(f);

	if (fs_cnt == 0)
		goto done;

	if (fs_cnt != fs_cnt_last) {
		fs_cnt_last = fs_cnt;
		goto again;
	}

	fail("Can't umount all the filesystems");
	return -1;

done:
	rmdir(MPTS_ROOT);
	if (mkdir(MPTS_ROOT, 0600) < 0) {
		fail("Can't make zdtm_sys");
		return 1;
	}

	if (mount("none", MPTS_ROOT, "sysfs", 0, "") < 0) {
		fail("Can't mount sysfs");
		return 1;
	}

	if (mount("none", MPTS_ROOT"/dev", "tmpfs", 0, "") < 0) {
		fail("Can't mount tmpfs");
		return 1;
	}
	tmpfs_fd = open(MPTS_ROOT"/dev/test", O_WRONLY | O_CREAT);
	if (write(tmpfs_fd, "hello", 5) <= 0) {
		err("write() failed");
		return 1;
	}

	if (mount("none", MPTS_ROOT"/kernel", "proc", 0, "") < 0) {
		fail("Can't mount proc");
		return 1;
	}
	if (mount("none", MPTS_ROOT"/kernel/sys/fs/binfmt_misc",
					"binfmt_misc", 0, "") < 0) {
		fail("Can't mount proc");
		return 1;
	}

	mknod("/dev/null", 0777 | S_IFCHR, makedev(1, 3));

	setup_outfile();

	fd = open(MPTS_ROOT"/kernel/meminfo", O_RDONLY);
	if (fd == -1)
		return 1;

	test_daemon();
	test_waitsig();

	/* this checks both -- sys and proc presence */
	if (access(MPTS_ROOT"/kernel/meminfo", F_OK)) {
		fail("No proc after restore");
		return 1;
	}

	pass();
	return 0;
}
开发者ID:OSLL,项目名称:pmover,代码行数:98,代码来源:mountpoints.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ passed函数代码示例发布时间:2022-05-30
下一篇:
C++ party_search函数代码示例发布时间: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