summaryrefslogtreecommitdiffstats
path: root/rtkit-test.c
diff options
context:
space:
mode:
authorDavid Henningsson <launchpad.web@epost.diwic.se>2010-02-07 13:59:21 +0100
committerLennart Poettering <lennart@poettering.net>2010-02-17 02:51:43 +0100
commit18a26fb38ff2422cb4839d76f5314bd09231c0e9 (patch)
tree185ffc96f653a9385a55753d426b246ae6ad1c5d /rtkit-test.c
parentd30db4ca250a2743872a525740d5177705072fda (diff)
rtkit: Add client-side testing of properties
To complete the previous patch that implemented properties in rtkit, here's the client-side code that tests that the properties work, and make them more accessible for the casual C programmer.
Diffstat (limited to 'rtkit-test.c')
-rw-r--r--rtkit-test.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/rtkit-test.c b/rtkit-test.c
index 2841b52..a6b79df 100644
--- a/rtkit-test.c
+++ b/rtkit-test.c
@@ -76,7 +76,8 @@ static void print_status(const char *t) {
int main(int argc, char *argv[]) {
DBusError error;
DBusConnection *bus;
- int r;
+ int r, max_realtime_priority, min_nice_level;
+ long long rttime_nsec_max;
struct rlimit rlim;
dbus_error_init(&error);
@@ -86,6 +87,21 @@ int main(int argc, char *argv[]) {
return 1;
}
+ if ((max_realtime_priority = rtkit_get_max_realtime_priority(bus)) < 0)
+ fprintf(stderr, "Failed to retrieve max realtime priority: %s\n", strerror(-max_realtime_priority));
+ else
+ printf("Max realtime priority is: %d\n", max_realtime_priority);
+
+ if ((r = rtkit_get_min_nice_level(bus, &min_nice_level)))
+ fprintf(stderr, "Failed to retrieve min nice level: %s\n", strerror(-r));
+ else
+ printf("Min nice level is: %d\n", min_nice_level);
+
+ if ((rttime_nsec_max = rtkit_get_rttime_nsec_max(bus)) < 0)
+ fprintf(stderr, "Failed to retrieve rttime limit: %s\n", strerror(-rttime_nsec_max));
+ else
+ printf("Rttime limit is: %lld ns\n", rttime_nsec_max);
+
memset(&rlim, 0, sizeof(rlim));
rlim.rlim_cur = rlim.rlim_max = 100000000ULL; /* 100ms */
if ((setrlimit(RLIMIT_RTTIME, &rlim) < 0))
@@ -96,14 +112,14 @@ int main(int argc, char *argv[]) {
if ((r = rtkit_make_high_priority(bus, 0, -10)) < 0)
fprintf(stderr, "Failed to become high priority: %s\n", strerror(-r));
else
- printf("Sucessfully became high priority.\n");
+ printf("Successfully became high priority.\n");
print_status("after high priority");
if ((r = rtkit_make_realtime(bus, 0, 10)) < 0)
fprintf(stderr, "Failed to become realtime: %s\n", strerror(-r));
else
- printf("Sucessfully became realtime.\n");
+ printf("Successfully became realtime.\n");
print_status("after realtime");