Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

rt_scheduler_test.c

Go to the documentation of this file.
00001 /*
00002  * rt_scheduler_test.c
00003  *
00004  * Copyright (c) 2004 The University of Utah and the Flux Group.
00005  * All rights reserved.
00006  *
00007  * This file is licensed under the terms of the GNU Public License.  
00008  * See the file "license.terms" for restrictions on redistribution 
00009  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
00010  */
00011 
00012 /**
00013  * @file rt_scheduler_test.c
00014  *
00015  * Test cases for the TimeSys implementation of the rt_scheduler interface.
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      * @test The rts_query_scheduler function.
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      * @test Creating an rts_schedulable for the current task.
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      * @test Creating an rts_schedulable, with a specific name, for the current
00065      * task.
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      * @test Creating two rts_schedulables and making sure the resource set is
00084      * not released until the first one is released.
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 }

Generated on Fri Oct 22 07:50:24 2004 for CPU Broker by  doxygen 1.3.9.1