clock_getres: Move dependencies to the new deps directory

Also, rename the binaries and directories as the test_
prefix is unnecessary.
Signed-off-by: NLucas Meneghel Rodrigues <lmr@redhat.com>
上级 939e2caa
CC = gcc
PROG = clock_getres
SRC = clock_getres.c
LIBS = -lrt
all: $(PROG)
$(PROG):
$(CC) $(LIBS) -o $(PROG) $(SRC)
clean:
rm -f $(PROG)
/*
* Test clock resolution for KVM guests that have kvm-clock or timebase
* as clock source
*
* Copyright (c) 2010 Red Hat, Inc
* Author: Lucas Meneghel Rodrigues <lmr@redhat.com>
*
* 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, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
struct timespec res;
int clock_return = clock_getres(CLOCK_MONOTONIC, &res);
char clocksource[50];
char line[80];
FILE *fr;
if ((fr = fopen(
"/sys/devices/system/clocksource/clocksource0/current_clocksource",
"rt")) == NULL) {
perror("fopen");
return EXIT_FAILURE;
}
while (fgets(line, 80, fr) != NULL) {
sscanf(line, "%s", &clocksource);
}
fclose(fr);
#if defined(__powerpc64__)
if (!strncmp(clocksource, "timebase", strlen("timebase"))) {
#else
if (!strncmp(clocksource, "kvm-clock", strlen("kvm-clock"))) {
#endif
if (clock_return == 0) {
if (res.tv_sec > 1 || res.tv_nsec > 100) {
printf("FAIL: clock_getres returned bad clock resolution\n");
return EXIT_FAILURE;
} else {
printf("PASS: check successful\n");
return EXIT_SUCCESS;
}
} else {
printf("FAIL: clock_getres failed\n");
return EXIT_FAILURE;
}
} else {
printf("FAIL: invalid clock source: %s\n", clocksource);
return EXIT_FAILURE;
}
}
import logging
import os
from autotest.client.shared import error
from virttest import utils_test
from virttest import utils_test, data_dir
@error.context_aware
......@@ -14,10 +14,10 @@ def run(test, params, env):
:param params: Dictionary with test parameters.
:param env: Dictionary with the test environment.
"""
source_name = "test_clock_getres/test_clock_getres.c"
source_name = os.path.join(test.virtdir, "deps", source_name)
dest_name = "/tmp/test_clock_getres.c"
bin_name = "/tmp/test_clock_getres"
source_name = "clock_getres/clock_getres.c"
source_name = os.path.join(data_dir.get_deps_dir(), source_name)
dest_name = "/tmp/clock_getres.c"
bin_name = "/tmp/clock_getres"
if not os.path.isfile(source_name):
raise error.TestError("Could not find %s" % source_name)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册