Ejemplo n.º 1
0
/**
 * argv[1]: file operation
 * argv[2]: file to test (with path)
 * argv[3]: file to test (without path)
 */
int main(int argc, char *argv[])
{
	if (argc != 4) {
		fprintf(stderr, "wrong argument number\n");
		return 1;
	}
	filepath = argv[2];
	filename = argv[3];

	/* create file and get the initial inode version */
	fd = creat(argv[2], O_RDWR);
	if (fd == -1) {
		fprintf(stderr, "failed to create file: %s\n", argv[2]);
		return 1;
	}

	old_inode_version = get_inode_version();

	if (strcmp(argv[1], "create") == 0) {
		printf("%d\n", old_inode_version);
		return 0;
	} else if (strcmp(argv[1], "chmod") == 0) {
		test_chmod();
	} else if (strcmp(argv[1], "chown") == 0) {
		test_chown();
	} else if (strcmp(argv[1], "read") == 0) {
		test_read();
	} else if (strcmp(argv[1], "write") == 0) {
		test_write();
	} else if (strcmp(argv[1], "mmap_read") == 0) {
		test_mmap_read();
	} else if (strcmp(argv[1], "mmap_write") == 0) {
		test_mmap_write();
	} else {
		fprintf(stderr, "wrong file operation: %s\n", argv[1]);
		return 1;
	}

	new_inode_version = get_inode_version();
#if 0
	fprintf(stderr, "test_inode_version: old - %d\n", old_inode_version);
	fprintf(stderr, "test_inode_version: new - %d\n", new_inode_version);
#endif
	/* wrong inode version, test failed */
	if (new_inode_version <= old_inode_version)
		return 1;

	printf("%d\n", new_inode_version);

	close(fd);

	return 0;
}
Ejemplo n.º 2
0
Archivo: test.c Proyecto: oooossss/mp3
int main()
{
	while(1){
	int number;
	printf("type in your test number: ");
	scanf("%d",&number);
	
	switch (number) {
		case 1:  test_create(); break;
		case 2:  test_close(); break;
		case 3:  test_createwait();break;
		case 4:  test_sig();break;
		case 5:  test_info();break;
		case 6:  test_chown();break;
		case 7:  test_chmod();break;
		case 8:  test_stat();break;
		default: printf("Wrong input test number");
	}
  }
}