00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "config.h"
00019
00020 #ifndef DEBUG
00021 #define DEBUG
00022 #endif
00023
00024 #include <string.h>
00025 #include <stdlib.h>
00026 #include <sys/types.h>
00027 #include <unistd.h>
00028
00029 #include <assert_pp.h>
00030
00031 #include <rk/rk.h>
00032 #include "rk_util.h"
00033 #include "rt_scheduler.h"
00034
00035 int main(int argc, char *argv[])
00036 {
00037 int retval = EXIT_SUCCESS;
00038
00039
00040
00041
00042 {
00043 struct rts_scheduler_data rsd;
00044
00045 ensure(rts_query_scheduler(&rsd) == 0);
00046 ensure(rsd.rsd_Flags & RSDF_RESERVATIONS);
00047 ensure(rsd.rsd_MaxReservable > 0.0);
00048 }
00049
00050
00051
00052
00053 {
00054 rts_schedulable_t rs;
00055
00056 ensure(rk_proc_get_rset(getpid()) == NULL_RESOURCE_SET);
00057 ensure(rts_grab_schedulable(&rs, getpid(), NULL) == 0);
00058 ensure(rk_proc_get_rset(getpid()) != NULL_RESOURCE_SET);
00059 ensure(rts_release_schedulable(rs) == 0);
00060 ensure(rk_proc_get_rset(getpid()) == NULL_RESOURCE_SET);
00061 }
00062
00063
00064
00065
00066
00067 {
00068 static const char *this_name = "rts_test";
00069 char rs_name[RK_NAME_LEN + 1];
00070 rk_resource_set_t this_rs;
00071 rts_schedulable_t rs;
00072
00073 ensure(rk_proc_get_rset(getpid()) == NULL_RESOURCE_SET);
00074 ensure(rts_grab_schedulable(&rs, getpid(), this_name) == 0);
00075 ensure((this_rs = rk_proc_get_rset(getpid())) != NULL_RESOURCE_SET);
00076 ensure(rk_resource_set_get_name(this_rs, rs_name) == 0);
00077 ensure(strcmp(rs_name, this_name) == 0);
00078 ensure(rts_release_schedulable(rs) == 0);
00079 ensure(rk_proc_get_rset(getpid()) == NULL_RESOURCE_SET);
00080 }
00081
00082
00083
00084
00085
00086 {
00087 rts_schedulable_t rs1, rs2;
00088
00089 ensure(rk_proc_get_rset(getpid()) == NULL_RESOURCE_SET);
00090 ensure(rts_grab_schedulable(&rs1, getpid(), NULL) == 0);
00091 ensure(rk_proc_get_rset(getpid()) != NULL_RESOURCE_SET);
00092 ensure(rts_grab_schedulable(&rs2, getpid(), NULL) == 0);
00093 ensure(rts_release_schedulable(rs2) == 0);
00094 ensure(rk_proc_get_rset(getpid()) != NULL_RESOURCE_SET);
00095 ensure(rts_release_schedulable(rs1) == 0);
00096 ensure(rk_proc_get_rset(getpid()) == NULL_RESOURCE_SET);
00097 }
00098
00099 return( retval );
00100 }