Esempio n. 1
0
int
main(int argc, char **argv)
{
    int                 fsfd;
    
    if (argc != 2) {
        fprintf(stderr,"usage: %s <filesystem>\n",
                argv[0]);
        exit(0);
    }

    fsfd = open(argv[1], O_RDONLY);
    if (fsfd < 0) {
	perror("open");
	exit(1);
    }
    
    printf("--- ioctl with bad output address\n");
    expect_error(ioctl(fsfd, XFS_IOC_FSCOUNTS, NULL), EFAULT);
    printf("--- ioctl with bad input address\n");
    expect_error(ioctl(fsfd, XFS_IOC_SET_RESBLKS, NULL), EFAULT);
    
    close(fsfd);
    
    return 0;
}
void
piglit_init(int argc, char **argv)
{
	GLuint vs, prog;
	int i,j;

	if (piglit_get_gl_version() < 20) {
		printf("Requires OpenGL 2.0\n");
		piglit_report_result(PIGLIT_SKIP);
	}

	piglit_require_extension("GL_ARB_ES2_compatibility");
	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);

	glClearColor(0.2, 0.2, 0.2, 0.2);

	vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vertShaderText);
	prog = piglit_link_simple_program(vs, 0);

	glUseProgram(prog);

	glVertexPointer(4, GL_FIXED, 0, verts);
	expect_error(GL_INVALID_ENUM, "glVertexPointer should not accept GL_FIXED.");
	glNormalPointer(GL_FIXED, 0, verts);
	expect_error(GL_INVALID_ENUM, "glNormalPointer should not accept GL_FIXED.");
	glColorPointer(4, GL_FIXED, 0, verts);
	expect_error(GL_INVALID_ENUM, "glColorPointer should not accept GL_FIXED.");
	glTexCoordPointer(4, GL_FIXED, 0, verts);
	expect_error(GL_INVALID_ENUM, "glTexCoordPointer should not accept GL_FIXED.");

	glEnableVertexAttribArray(0);
	glVertexAttribPointer(0, 4, GL_FIXED, GL_FALSE, 0, verts);
	expect_error(GL_NO_ERROR, "glVertexAttribPointer should accept GL_FIXED.");

	for (i = 0; i < 4; i++) {
		for (j = 0; j < 4; j++) {
			verts[(i*4+j)*4+0] = ((opos[i*2+0] + vpos[j*2+0]) << 16) |
					     (unsigned)(ocol[i*4+0] * 65535);
			verts[(i*4+j)*4+1] = ((opos[i*2+1] + vpos[j*2+1]) << 16) |
					     (unsigned)(ocol[i*4+1] * 65535);
			verts[(i*4+j)*4+2] = (unsigned)(ocol[i*4+2] * 65535);
			verts[(i*4+j)*4+3] = (1 << 16) |
					     (unsigned)(ocol[i*4+3] * 65535);
		}
	}
}
Esempio n. 3
0
static void test_matrix(void)
{
	GLuint vs, fs;
	GLuint program;
	GLint loc_a, loc_b, loc_c;
	GLint loc_b2;
	const char * glsl_type = "mat4";

	vs = compile_shader(GL_VERTEX_SHADER_ARB, vs_matrix_template);
	fs = compile_shader(GL_FRAGMENT_SHADER_ARB, fs_matrix_template);
	program = link_program(vs, fs);

	glUseProgramObjectARB(program);
	loc_a = glGetUniformLocationARB(program, "a");
	loc_b = glGetUniformLocationARB(program, "b");
	loc_c = glGetUniformLocationARB(program, "c");
	loc_b2 = glGetUniformLocationARB(program, "b[2]");
	printf("locations: a: %i b: %i c: %i b[2]: %i\n", loc_a, loc_b, loc_c, loc_b);

	expect_error(GL_NO_ERROR, "Type %s: Sanity check", glsl_type);

	glUniformMatrix4fvARB(loc_b, 0, GL_FALSE, lots_of_zeros);
	expect_error(GL_NO_ERROR, "Type %s: Write count = 0 to b", glsl_type);
	glUniformMatrix4fvARB(loc_b, 1, GL_FALSE, lots_of_zeros);
	expect_error(GL_NO_ERROR, "Type %s: Write count = 1 to b", glsl_type);
	glUniformMatrix4fvARB(loc_b, 4, GL_FALSE, lots_of_zeros);
	expect_error(GL_NO_ERROR, "Type %s: Write count = 4 to b", glsl_type);

	/* Out of bounds; see comment above */
	glUniformMatrix4fvARB(loc_b, 5, GL_FALSE, lots_of_zeros);
	(void) glGetError(); /* Eat generated error, if any */

	glUniformMatrix4fvARB(loc_c, 0, GL_FALSE, lots_of_zeros);
	expect_error(GL_NO_ERROR, "Type %s: Write count = 0 to c", glsl_type);
	glUniformMatrix4fvARB(loc_c, 1, GL_FALSE, lots_of_zeros);
	expect_error(GL_NO_ERROR, "Type %s: Write count = 1 to c", glsl_type);
	glUniformMatrix4fvARB(loc_c, 4, GL_FALSE, lots_of_zeros);
	expect_error(GL_NO_ERROR, "Type %s: Write count = 4 to c", glsl_type);

	/* Out of bounds; see comment above */
	glUniformMatrix4fvARB(loc_c, 5, GL_FALSE, lots_of_zeros);
	(void) glGetError(); /* Eat generated error, if any */

	glUniformMatrix4fvARB(loc_b2, 0, GL_FALSE, lots_of_zeros);
	expect_error(GL_NO_ERROR, "Type %s: Write count = 0 to b[2]", glsl_type);
	glUniformMatrix4fvARB(loc_b2, 2, GL_FALSE, lots_of_zeros);
	expect_error(GL_NO_ERROR, "Type %s: Write count = 2 to b[2]", glsl_type);

	/* Out of bounds; see comment above */
	glUniformMatrix4fvARB(loc_b2, INT_MAX, GL_FALSE, lots_of_zeros);
	(void) glGetError(); /* Eat generated error, if any */

	glUniformMatrix4fvARB(loc_a, 0, GL_FALSE, lots_of_zeros);
	expect_error(GL_NO_ERROR, "Type %s: Write count = 0 to a", glsl_type);
	glUniformMatrix4fvARB(loc_a, 1, GL_FALSE, lots_of_zeros);
	expect_error(GL_NO_ERROR, "Type %s: Write count = 1 to a", glsl_type);
	glUniformMatrix4fvARB(loc_a, 2, GL_FALSE, lots_of_zeros);
	expect_error(GL_INVALID_OPERATION, "Type %s: Write count = 2 to a", glsl_type);
	glUniformMatrix4fvARB(loc_a, INT_MAX, GL_FALSE, lots_of_zeros);
	expect_error(GL_INVALID_OPERATION, "Type %s: Write count = INT_MAX to a", glsl_type);

	glDeleteObjectARB(fs);
	glDeleteObjectARB(vs);
	glDeleteObjectARB(program);
}
Esempio n. 4
0
static void test_vector(const char *glsl_type, const char * suffix,
		void (GLAPIENTRY *uniform)(GLint, GLsizei, const GLfloat*))
{
	char buffer[2*sizeof(vs_vector_template)];
	GLuint vs, fs;
	GLuint program;
	GLint loc_a, loc_b, loc_c;
	GLint loc_b2;

	snprintf(buffer, sizeof(buffer), vs_vector_template,
		glsl_type, glsl_type, glsl_type, glsl_type);
	vs = compile_shader(GL_VERTEX_SHADER_ARB, buffer);

	snprintf(buffer, sizeof(buffer), fs_vector_template,
		glsl_type, suffix);
	fs = compile_shader(GL_FRAGMENT_SHADER_ARB, buffer);

	program = link_program(vs, fs);

	glUseProgramObjectARB(program);
	loc_a = glGetUniformLocationARB(program, "a");
	loc_b = glGetUniformLocationARB(program, "b");
	loc_c = glGetUniformLocationARB(program, "c");
	loc_b2 = glGetUniformLocationARB(program, "b[2]");
	printf("locations: a: %i b: %i c: %i b[2]: %i\n", loc_a, loc_b, loc_c, loc_b);

	expect_error(GL_NO_ERROR, "Type %s: Sanity check", glsl_type);
	uniform(loc_a, 0, lots_of_zeros);
	expect_error(GL_NO_ERROR, "Type %s: Write count = 0 to a", glsl_type);
	uniform(loc_a, 1, lots_of_zeros);
	expect_error(GL_NO_ERROR, "Type %s: Write count = 1 to a", glsl_type);
	uniform(loc_a, 2, lots_of_zeros);
	expect_error(GL_INVALID_OPERATION, "Type %s: Write count = 2 to a", glsl_type);
	uniform(loc_a, 1024, lots_of_zeros);
	expect_error(GL_INVALID_OPERATION, "Type %s: Write count = 1024 to a", glsl_type);

	uniform(loc_b, 0, lots_of_zeros);
	expect_error(GL_NO_ERROR, "Type %s: Write count = 0 to b", glsl_type);
	uniform(loc_b, 1, lots_of_zeros);
	expect_error(GL_NO_ERROR, "Type %s: Write count = 1 to b", glsl_type);
	uniform(loc_b, 4, lots_of_zeros);
	expect_error(GL_NO_ERROR, "Type %s: Write count = 4 to b", glsl_type);

	/* Note: The following are out of bound for the array,
	 * but the spec situation is a bit unclear as to whether errors
	 * should be generated.
	 *
	 * Issue #32 of the ARB_shader_objects spec suggests errors
	 * should be generated when writing out-of-bounds on arrays,
	 * but this is not reflected in the OpenGL spec.
	 *
	 * The main point of these tests is to make sure the driver
	 * does not introduce memory errors by accessing internal arrays
	 * out of bounds.
	 */
	uniform(loc_b, 5, lots_of_zeros);
	(void) glGetError(); /* Eat generated error, if any */

	uniform(loc_c, 0, lots_of_zeros);
	expect_error(GL_NO_ERROR, "Type %s: Write count = 0 to c", glsl_type);
	uniform(loc_c, 1, lots_of_zeros);
	expect_error(GL_NO_ERROR, "Type %s: Write count = 1 to c", glsl_type);
	uniform(loc_c, 4, lots_of_zeros);
	expect_error(GL_NO_ERROR, "Type %s: Write count = 4 to c", glsl_type);

	/* Out of bounds; see comment above */
	uniform(loc_c, 5, lots_of_zeros);
	(void) glGetError(); /* Eat generated error, if any */

	uniform(loc_b2, 0, lots_of_zeros);
	expect_error(GL_NO_ERROR, "Type %s: Write count = 0 to b[2]", glsl_type);
	uniform(loc_b2, 2, lots_of_zeros);
	expect_error(GL_NO_ERROR, "Type %s: Write count = 2 to b[2]", glsl_type);

	/* Out of bounds; see comment above */
	uniform(loc_b2, 1024, lots_of_zeros);
	(void) glGetError(); /* Eat generated error, if any */

	glDeleteObjectARB(fs);
	glDeleteObjectARB(vs);
	glDeleteObjectARB(program);
}