Skip to content

Commit

Permalink
Add permissions test for sputrace
Browse files Browse the repository at this point in the history
Signed-off-by: Jeremy Kerr <[email protected]>
  • Loading branch information
jk-ozlabs committed Mar 4, 2009
1 parent ca5e44a commit 3c09607
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
55 changes: 55 additions & 0 deletions tests/21-sputrace/02-permissions.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Testsuite for the Linux SPU filesystem
*
* Copyright (C) IBM Corporation, 2008
*
* Author: Jeremy Kerr <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#define _ATFILE_SOURCE

#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>

int main(void)
{
struct stat statbuf;
int rc;

rc = stat("/proc/sputrace", &statbuf);
if (rc) {
perror("stat(/proc/sputrace)");
return EXIT_FAILURE;
}

if (statbuf.st_mode != (S_IFREG | S_IRUSR)) {
fprintf(stderr, "invalid mode: %04o\n", statbuf.st_mode);
return EXIT_FAILURE;
}

if (statbuf.st_uid != 0) {
fprintf(stderr, "invalid user: %d\n", statbuf.st_uid);
return EXIT_FAILURE;
}

if (statbuf.st_gid != 0) {
fprintf(stderr, "invalid group: %d\n", statbuf.st_gid);
return EXIT_FAILURE;
}

return EXIT_SUCCESS;
}
2 changes: 1 addition & 1 deletion tests/21-sputrace/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
# along with this program; if not, write to the Free Software
# Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

obj += 01-sputrace-read
obj += 01-sputrace-read 02-permissions

0 comments on commit 3c09607

Please sign in to comment.