mirror of
				https://github.com/tiagovignatti/intel-gpu-tools.git
				synced 2025-11-04 12:07:12 +00:00 
			
		
		
		
	sysfs_rps: Add negative test case for bad values
Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
This commit is contained in:
		
							parent
							
								
									50d46750d9
								
							
						
					
					
						commit
						dc3ac00f03
					
				@ -74,12 +74,20 @@ static int readval(FILE *filp)
 | 
			
		||||
	return val;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void writeval(FILE *filp, int val)
 | 
			
		||||
static int do_writeval(FILE *filp, int val, int lerrno)
 | 
			
		||||
{
 | 
			
		||||
	/* Must write twice to sysfs since the first one simply calculates the size and won't return the error */
 | 
			
		||||
	int ret;
 | 
			
		||||
	rewind(filp);
 | 
			
		||||
	fprintf(filp, "%d", val);
 | 
			
		||||
	ret = fprintf(filp, "%d", val);
 | 
			
		||||
	rewind(filp);
 | 
			
		||||
	ret = fprintf(filp, "%d", val);
 | 
			
		||||
	if (ret && lerrno)
 | 
			
		||||
		assert(errno = lerrno);
 | 
			
		||||
	fflush(filp);
 | 
			
		||||
	return ret;
 | 
			
		||||
}
 | 
			
		||||
#define writeval(filp, val) do_writeval(filp, val, 0)
 | 
			
		||||
 | 
			
		||||
#define fcur (readval(stuff[CUR].filp))
 | 
			
		||||
#define fmin (readval(stuff[MIN].filp))
 | 
			
		||||
@ -176,6 +184,9 @@ int main(int argc, char *argv[])
 | 
			
		||||
	writeval(stuff[MAX].filp, fmin - 1);
 | 
			
		||||
	checkit();
 | 
			
		||||
 | 
			
		||||
	do_writeval(stuff[MIN].filp, 0x11111110, EINVAL);
 | 
			
		||||
	do_writeval(stuff[MAX].filp, 0, EINVAL);
 | 
			
		||||
 | 
			
		||||
	writeval(stuff[MIN].filp, origmin);
 | 
			
		||||
	writeval(stuff[MAX].filp, origmax);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user