GridLab
Grid Application Toolkit

A simple API for Grid Applications
GAT

Menu



Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members  

advertservice_find_tests.c

Go to the documentation of this file.
00001 /** @file advertservice_getadvertisable_tests.c
00002  *
00003  *  Tests the GATAdvertService_GetAdvertisable functionality
00004  * 
00005  *  @date Sun Mar 21 2004
00006  * 
00007  *  @version $Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/test/simple/advertservice_find_tests.c,v 1.4 2004/04/20 17:04:59 hartmutkaiser Exp $
00008  *
00009  *  Copyright (C) Hartmut Kaiser
00010  *  This file is part of the GAT Engine.
00011  *  Contributed by Hartmut Kaiser <hartmutkaiser [at] t-online [dot] de>.
00012  *
00013  *  Use, modification and distribution is subject to the Gridlab Software
00014  *  License. (See accompanying file GLlicense.txt or copy at
00015  *  http://www.gridlab.org/GLlicense.txt)
00016  */
00017 
00018 static const char *rcsid = "$Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/test/simple/advertservice_find_tests.c,v 1.4 2004/04/20 17:04:59 hartmutkaiser Exp $";
00019 
00020 /* System Header Files */
00021 
00022 #include <stdio.h>
00023 #include <stdlib.h>
00024 #include <string.h>
00025 
00026 /* GAT Header Files */
00027 
00028 #include "GAT.h"
00029 #include "GATTestUtils.h"
00030 
00031 /* Macros */
00032 
00033 /* Structures, unions and enums */
00034 
00035 /* Static function prototypes */
00036 
00037 /* File scope variables */
00038 
00039 /* External functions */
00040 
00041 int main(int argc, const char * const argv[])
00042 {
00043   GATContext context = NULL;
00044   GATAdvertService advertservice = NULL;
00045   GATResult   retval   = GAT_SUCCESS;
00046   char const *pathstr  = "/AdvertServiceTests/Files/MyCheckpointFile";
00047   GATTable    metadata = NULL;
00048   GATList_String paths = NULL;
00049 
00050   GAT_TEST_INIT  (-1);
00051   GAT_TEST_SUITE ("AdvertService")
00052 
00053   context = GATContext_Create();
00054   GAT_TEST(NULL != context);
00055   
00056   /* the following test makes sure, that there were no errors during the 
00057      creation of the GATContext object */
00058   GAT_TEST_TRACE(GATType_GATContext == GATContext_GetType(context), context);
00059 
00060   GAT_TEST_START ("AdvertService Find Test");
00061 
00062   advertservice = GATAdvertService_Create(context, 0);
00063   GAT_TEST_TRACE(NULL != advertservice, context);
00064 
00065   /* construct the metadata to search for */
00066   metadata = GATTable_Create();
00067   GAT_TEST_TRACE(NULL != metadata, context);
00068 
00069   /* add the metadata patterns to the table */
00070   retval = GATTable_Add_String(metadata, "GATJobid", "GAT_JOBID:.*");
00071   GAT_TEST_TRACE(GAT_SUCCEEDED(retval), context);
00072 
00073   /* get the associated metadata from the advertservice */
00074   retval = GATAdvertService_Find(advertservice, metadata, &paths);
00075   GAT_TEST_TRACE(GAT_SUCCEEDED(retval), context);
00076 
00077   /* the list should contain only the pathstr path */
00078   {
00079     GATList_String_Iterator it = GATList_String_Begin(paths);
00080     GATList_String_Iterator end = GATList_String_End(paths);
00081   
00082     for (/**/; it != end; it = GATList_String_Next(it))
00083     {
00084       char const *path = GATList_String_Get(it);
00085       GAT_TEST(!strcmp(path, pathstr));
00086     }
00087   }
00088   
00089   /* free all the allocated memory */
00090   GATList_String_Destroy(&paths);
00091   GATTable_Destroy(&metadata);
00092   GATAdvertService_Destroy(&advertservice);
00093   GATContext_Destroy(&context);
00094 
00095   GAT_TEST_STOP ();
00096   GAT_TEST_FINISH();
00097 
00098   return 0;
00099 }
00100