GridLab
Grid Application Toolkit

A simple API for Grid Applications
GAT

Menu



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

file_isreadable_tests.c

Go to the documentation of this file.
00001 /** @file file_isreadable.c
00002  * Example of using the GAT to test the readability of a file.
00003  * 
00004  * Uses the GAT to test if a file at a given URI is readable.
00005  * 
00006  * @date Mon Oct 6 2003
00007  * 
00008  * @version $Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/test/simple/file_isreadable_tests.c,v 1.8 2004/04/20 17:04:59 hartmutkaiser Exp $
00009  *
00010  *  Copyright (C) Hartmut Kaiser
00011  *  This file is part of the GAT Engine.
00012  *  Contributed by Hartmut Kaiser <hartmutkaiser [at] t-online [dot] de>.
00013  *
00014  *  Use, modification and distribution is subject to the Gridlab Software
00015  *  License. (See accompanying file GLlicense.txt or copy at
00016  *  http://www.gridlab.org/GLlicense.txt)
00017  */
00018 
00019 static const char *rcsid = "$Header: /export/cvs-gridlab/wp-1/Codes/GATEngine/C-reference/test/simple/file_isreadable_tests.c,v 1.8 2004/04/20 17:04:59 hartmutkaiser Exp $";
00020 
00021 
00022 /* System Header Files */
00023 
00024 #include <stdio.h>
00025 #include <stdlib.h>
00026 
00027 
00028 /* GAT Header Files */
00029 
00030 #include <GAT.h>
00031 #include <GATTestUtils.h>
00032 
00033 
00034 /* External functions */
00035 
00036 int main (void)
00037 {
00038   GATResult   retcode = GAT_SUCCESS;
00039   GATContext  context = NULL;
00040   GATLocation target  = NULL;
00041   GATFile     file    = NULL;
00042   const char* src     = NULL;
00043 
00044   GAT_TEST_INIT  (-1);
00045   GAT_TEST_SUITE ("File")
00046 
00047   context = GATContext_Create();
00048   GAT_TEST(NULL != context);
00049   
00050   /* the following test makes sure, that there were no errors during the 
00051      creation of the GATContext object */
00052   GAT_TEST_TRACE(GATType_GATContext == GATContext_GetType(context), context);
00053 
00054   GAT_TEST_START ("File IsReadable Test");
00055 
00056   src = GATTest_CreateTempFile ("gat_src");
00057   GAT_TEST_TRACE (NULL != src, context);
00058 
00059   target = GATLocation_Create(src);
00060   GAT_TEST_TRACE (NULL != target, context);
00061 
00062   file = GATFile_Create (context, target, 0);
00063   GAT_TEST_TRACE (NULL != file, context);
00064   
00065   retcode = GATFile_IsReadable (file);
00066   GAT_TEST_TRACE (GAT_FALSE          != retcode, context);
00067   GAT_TEST_TRACE (GAT_FILEOPEN_ERROR != retcode, context);
00068   GAT_TEST_TRACE (GAT_SUCCESS        == retcode, context);
00069         
00070   GATFile_Destroy     (&file);
00071   GATLocation_Destroy (&target);
00072   GATContext_Destroy  (&context);
00073 
00074   GAT_TEST_STOP ();
00075   GAT_TEST_FINISH();
00076 
00077   return (retcode);
00078 }
00079