selftests: sync: differentiate between sync unsupported and access errors
Sync test doesn't differentiate between sync unsupported and test run by non-root user and treats both as unsupported cases. Fix it to add handling for these two different scenarios. Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com> Reviewed-by: Gustavo Padovan <gustavo.padovan@collabora.com>
This commit is contained in:
Родитель
97e4936851
Коммит
f6c44bbb79
|
@ -31,6 +31,7 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#include "synctest.h"
|
#include "synctest.h"
|
||||||
|
|
||||||
|
@ -56,18 +57,32 @@ static int run_test(int (*test)(void), char *name)
|
||||||
static int sync_api_supported(void)
|
static int sync_api_supported(void)
|
||||||
{
|
{
|
||||||
struct stat sbuf;
|
struct stat sbuf;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = stat("/sys/kernel/debug/sync/sw_sync", &sbuf);
|
||||||
|
if (!ret)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (errno == ENOENT) {
|
||||||
|
printf("SKIP: Sync framework not supported by kernel\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
if (errno == EACCES) {
|
||||||
|
printf("SKIP: Run Sync test as root.\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
perror("stat");
|
||||||
|
exit(ret);
|
||||||
|
|
||||||
return 0 == stat("/sys/kernel/debug/sync/sw_sync", &sbuf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
if (!sync_api_supported()) {
|
if (!sync_api_supported())
|
||||||
printf("SKIP: Sync framework not supported by kernel\n");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
|
|
||||||
printf("[RUN]\tTesting sync framework\n");
|
printf("[RUN]\tTesting sync framework\n");
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче