int main(int argc, char** argv)
{
  char cwd[512];
  char path[512];

  cwd[0] = 0;
  if (! getcwd(cwd, sizeof(cwd)))
    perror("getcwd");
  strcat(cwd, "/");

  snprintf(path, sizeof(path), "/proc/%d/cmdline", getpid());

  test_cmdline(cwd, "/proc/self/cmdline", "/proc/self/cmdline");
  test_cmdline(cwd, "/proc/<pid>/cmdline", path);

  snprintf(path, sizeof(path), "/proc/%d/exe", getpid());

  test_readlink(cwd, "/proc/self/exe", "/proc/self/exe");
  test_readlink(cwd, "/proc/<pid>/exe", path);

  test_readlinkat(cwd, "/proc/self/exe", "/proc/self/exe");
  test_readlinkat(cwd, "/proc/<pid>/exe", path);

  return 0;
}
예제 #2
0
int main(void)
{
	struct test_case *tc;
	int test_rc;
	int rc = 0;

	for (tc = test_cases; tc < test_cases + ARRAY_SIZE(test_cases); tc++) {
		if (getenv("ETHTOOL_TEST_VERBOSE"))
			printf("I: Test command line: ethtool %s\n", tc->args);
		test_rc = test_cmdline(tc->args);
		if (test_rc != tc->rc) {
			fprintf(stderr, "E: ethtool %s returns %d\n",
				tc->args, test_rc);
			rc = 1;
		}
	}

	return rc;
}