Example #1
0
/**
 *Test SIZE of a nameEntry and if it end by \0
 *return the size of the nameEntry
 */
int testNameEntry(char* nameEntry){
	error er;
	int ASCII_END_FOUND = 0;
	int sizeNameEntry=0;
	int i;
	for (i = 0; i < SIZE_MAX_NAME_ENTRY; i++) {
		if (nameEntry[i] == '\0') {
			sizeNameEntry=i;
			ASCII_END_FOUND = 1;
			break;
		}
		sizeNameEntry++;
	}
	if(sizeNameEntry<1){
		er.val = 1;
		er.message = "the name of the folder is smaller than 1 characters :\n";
		testerror(er);
	}

	if (!ASCII_END_FOUND) {
		er.val = 1;
		er.message = "the name of the folder is bigger than  SIZE_MAX_NAME_ENTRY :\n ";
		testerror(er);
	}
	return sizeNameEntry;
}
Example #2
0
/****************************************************************************
*
*						Subroutine start_logger
*
*	Purpose: 	This function will start up the tracelogger, and
*				clear any filters that may be in place.
*
*	Returns: 	Pid of the tracelogger
*
*****************************************************************************/
int start_logger(void) 
{
	int tlpid,rc;
	char buf[100];
	snprintf(buf, sizeof(buf), "-n%d", NUM_ITER);

	tlpid=spawnlp(P_NOWAIT, "tracelogger", "tracelogger",buf, "-d", NULL);
	if (tlpid==-1) {
		snprintf(buf,sizeof(buf), "Unable to start tracelogger (%s)", strerror(errno));
		testerror(buf);
		teststop("Bad");
		exit(0);
	}
	rc=TraceEvent(_NTO_TRACE_DELALLCLASSES);
	assert(rc!=-1);
	rc=TraceEvent(_NTO_TRACE_CLRCLASSPID, _NTO_TRACE_KERCALL);
	assert(rc!=-1);
	rc=TraceEvent(_NTO_TRACE_CLRCLASSTID, _NTO_TRACE_KERCALL);
	assert(rc!=-1);
	rc=TraceEvent(_NTO_TRACE_CLRCLASSPID, _NTO_TRACE_THREAD);
	assert(rc!=-1);
	rc=TraceEvent(_NTO_TRACE_CLRCLASSTID, _NTO_TRACE_THREAD);
	assert(rc!=-1);
	rc=TraceEvent(_NTO_TRACE_CLRCLASSPID, _NTO_TRACE_VTHREAD);
	assert(rc!=-1);
	rc=TraceEvent(_NTO_TRACE_CLRCLASSTID, _NTO_TRACE_VTHREAD);
	assert(rc!=-1);
	return(tlpid);
}
Example #3
0
/**
 * Test if the PATH start with FILE://
 */
void testStartOfPath(const char *path) {
	if (path[0] == 'F' && path[1] == 'I' && path[2] == 'L' && path[3] == 'E'
			&& path[4] == ':' && path[5] == '/' && path[6] == '/') {
	}
	else {
		error er;
		er.val = 1;
		er.message = "The PATH do not start with FILE://";
		testerror(er);
	}
}
Example #4
0
int main(int argc, char* argv[]) {

	FILE* fp = fopen("/etc/passwd", "w");
	
	if (!fp) {
		/*
		puts("Shucks, couldn't write /etc/passwd");
		show_errno();
		perror("main (write /etc/passwd)");
		perror("NULL");
		perror("");
		*/
		MYERR(stderr,"");
		
	}
	
	show_errno();
	testerror();
	show_errno();
	
	/*
	show_errno();
	if(chdir("/does/not/exist")){
		// myerror(stderr,__FUNCTION__,"chdir dne");		
		//__FUNCTION__ always resolves to current function we are in
		MYERR(stderr, "chdir dne");
	}
	
	
	show_errno();
	if (chdir("..")) {
		perror("main (chdir dne)");
	}	

	show_errno();
	*/
	
	return 0;
}
Example #5
0
int main(int argc, char *argv[]) {

	if (argc > 2 && strcmp(argv[1], "-s") == 0) {

		int size;
		int valReturn = sscanf(argv[2], "%d", &size);

		if (valReturn != 1 || size < 2) {
			fprintf(stderr, "tfs_create -s need 1 argument :"
					" the size enter :  %d  is not CORRECT \n", size);
			return 1;

		} else {
			error er;
			disk_id *disk = malloc(sizeof(*disk));
			if(disk==NULL){
				er.val=1;
				er.message="ERROR MALLOC DISK in TFS_CREATE";
				testerror(er);
			}

			char* nameFile;

			if (argc > 3) {  //the user give a name to the file
				nameFile = argv[3];
			} else {
				nameFile = "disk.tfs";
			}

			er = createFile(nameFile);
			testerror(er);
			er = start_disk(nameFile, disk);
			testerror(er);

			int sizeInOctal = size * 1024;

			/*
			 int i=0;
			 for(i; i<sizeInOctal;i++){
			 fputc(45,r);
			 }

			 ftruncate(fileno(r) sizeInOctal);
			 deplace le curseur a la position max-1
			 */
			fseek(disk->fichier, (sizeInOctal - 1), SEEK_CUR);
			fputc(0, disk->fichier); //ecris un octet en position max
			//Il faut reouvrir le fichier en mode binaire apres avoir fait un fputc
			fseek(disk->fichier, 0, SEEK_CUR);
			stop_disk(*disk);

			er = start_disk(nameFile, disk);
			testerror(er);
			block *b;
			b = initBlock();
			free(b->valeur[0]);
			b->valeur[0] = valueToNombre32bits(size);
			//b->valeur[1] = valueToNombre32bits(1);// there is 1 partition at first
			//b->valeur[2] = valueToNombre32bits(size-1);
			er=write_block(*disk, *b, 0);
			testerror(er);

			/*
			 read_block(*disk,*b,0);
			 printf("dans fonction afficahge de block apres read\n");
			 printBlock(b);
			 */
			er=stop_disk(*disk);
			testerror(er);
			freeBlock(b);
			freeDisk(disk);
			return 0;
		}
	} else {
		fprintf(stderr,
				"tfs_create need at minimum 1 argument :\n -s "
						"follow by the size ( a POSITIVE NUMBER)of "
						"the new tfs\n [name] is optional,  it is the name of the tfs\n");
		return 1;
	}
	return 0;
}
Example #6
0
void
t4()
{
	testerror("error1");
	testerror("error2");
}
Example #7
0
void
t3()
{
	testerror("error1");
}