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

real_time_schedule.cc

Go to the documentation of this file.
00001 /*
00002  * real_time_schedule.cc
00003  *
00004  * Copyright (c) 2003 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 real_time_schedule.cc
00014  *
00015  * Test cases for the RealTimeSchedule class.
00016  */
00017 
00018 #include "config.h"
00019 
00020 #if !defined(DEBUG)
00021 #define DEBUG 1
00022 #endif
00023 
00024 #include <iostream>
00025 
00026 #include <assert.h>
00027 
00028 #include <RealTimeSchedule.hh>
00029 
00030 int main(int argc, char *argv[])
00031 {
00032     int retval = 0;
00033 
00034     /* Test a simple case where period == deadline. */
00035     {
00036         RealTimeSchedule rts(0, 1000, 1000);
00037         
00038         assert(rts.intersect(0, 1000) == 1000);
00039         assert(rts.intersect(250, 1000) == 750);
00040         assert(rts.intersect(500, 1000) == 500);
00041 
00042         assert(rts.intersect(0, 5000) == 5000);
00043         assert(rts.intersect(250, 5000) == 4750);
00044         assert(rts.intersect(500, 5000) == 4500);
00045 
00046         assert(rts.intersect(0, 750) == 750);
00047         assert(rts.intersect(0, 500) == 500);
00048 
00049         assert(rts.intersect(250, 750) == 500);
00050         assert(rts.intersect(500, 750) == 250);
00051         assert(rts.intersect(500, 500) == 0);
00052     }
00053 
00054     /* Test for deadline < period. */
00055     {
00056         RealTimeSchedule rts(0, 1000, 500);
00057         
00058         assert(rts.intersect(0, 1000) == 500);
00059         assert(rts.intersect(250, 1000) == 250);
00060         assert(rts.intersect(500, 1000) == 0);
00061 
00062         assert(rts.intersect(0, 5000) == 2500);
00063         assert(rts.intersect(250, 5000) == 2250);
00064         assert(rts.intersect(500, 5000) == 2000);
00065     }
00066 
00067     /* Test for start time. */
00068     {
00069         RealTimeSchedule rts(500, 500, 500);
00070         
00071         assert(rts.intersect(0, 1000) == 500);
00072         assert(rts.intersect(500, 1000) == 500);
00073         assert(rts.intersect(250, 750) == 250);
00074         assert(rts.intersect(500, 750) == 250);
00075     }
00076     
00077     {
00078         RealTimeSchedule rts(750, 1000, 500);
00079         
00080         assert(rts.intersect(1000, 2000) == 500);
00081     }
00082     
00083     return( retval );
00084 }

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