/* $Id: cpl_plugin-test.c,v 1.7 2007/07/16 09:09:04 llundin Exp $ * * This file is part of the ESO Common Pipeline Library * Copyright (C) 2001-2005 European Southern Observatory * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* * $Author: llundin $ * $Date: 2007/07/16 09:09:04 $ * $Revision: 1.7 $ * $Name: $ */ #undef CX_DISABLE_ASSERT #undef CX_LOG_DOMAIN #include #include #include #include "cpl_init.h" #include "cpl_plugin.h" int main(void) { /* FIXME Implement cleanup after an error has occured! */ cpl_plugin *plgn1; int ecode; unsigned int api1 = 1, aapi1; unsigned long version1 = 10000L, aversion1, type1 = 1L, atype1; const char *sversion1 = "1.0.0", *asversion1, *stype1 = "recipe", *astype1, *sname1 = "eso.cpl.test", *asname1, *ssynopsis1 = "test_synopsis", *assynopsis1, *sdescription1 = "test_description", *asdescription1, *sauthor1 = "test_author", *asauthor1, *semail1 = "test_email", *asemail1, *scopyright1 = "test_copyright", *ascopyright1; cpl_plugin_func initialize1 = (cpl_plugin_func)1, ainitialize1, execute1 = (cpl_plugin_func)1, aexecute1, deinitialize1 = (cpl_plugin_func)1, adeinitialize1; cpl_init(CPL_INIT_DEFAULT); /* * Test1 : Accessor Functions */ plgn1 = cpl_plugin_new(); if (plgn1==NULL) { cpl_end(); return 1; } /* PLUGIN API */ ecode = 0; ecode = cpl_plugin_set_api(plgn1, api1); if (ecode!=0) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } aapi1 = cpl_plugin_get_api(plgn1); if (aapi1!=api1) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } /* PLUGIN VERSION */ ecode = 0; ecode = cpl_plugin_set_version(plgn1, version1); if (ecode!=0) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } aversion1 = cpl_plugin_get_version(plgn1); if (aversion1!=version1) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } asversion1 = cpl_plugin_get_version_string(plgn1); if (strcmp(sversion1,asversion1)!=0) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } cx_free((char*)asversion1); /* PLUGIN TYPE */ ecode = 0; ecode = cpl_plugin_set_type(plgn1, type1); if (ecode!=0) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } atype1 = cpl_plugin_get_type(plgn1); if (atype1!=type1) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } astype1 = cpl_plugin_get_type_string(plgn1); if (strcmp(stype1,astype1)!=0) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } cx_free((char*)astype1); /* PLUGIN NAME */ ecode = 0; ecode = cpl_plugin_set_name(plgn1, sname1); if (ecode!=0) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } asname1 = cpl_plugin_get_name(plgn1); if (strcmp(sname1,asname1)!=0) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } /* PLUGIN SYNOPSIS */ ecode = 0; ecode = cpl_plugin_set_synopsis(plgn1, ssynopsis1); if (ecode!=0) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } assynopsis1 = cpl_plugin_get_synopsis(plgn1); if (strcmp(ssynopsis1,assynopsis1)!=0) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } /* PLUGIN DESCRIPTION */ ecode = 0; ecode = cpl_plugin_set_description(plgn1, sdescription1); if (ecode!=0) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } asdescription1 = cpl_plugin_get_description(plgn1); if (strcmp(sdescription1,asdescription1)!=0) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } /* PLUGIN AUTHOR */ ecode = 0; ecode = cpl_plugin_set_author(plgn1, sauthor1); if (ecode!=0) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } asauthor1 = cpl_plugin_get_author(plgn1); if (strcmp(sauthor1,asauthor1)!=0) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } /* PLUGIN EMAIL */ ecode = 0; ecode = cpl_plugin_set_email(plgn1, semail1); if (ecode!=0) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } asemail1 = cpl_plugin_get_email(plgn1); if (strcmp(semail1,asemail1)!=0) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } /* PLUGIN COPYRIGHT */ ecode = 0; ecode = cpl_plugin_set_copyright(plgn1, scopyright1); if (ecode!=0) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } ascopyright1 = cpl_plugin_get_copyright(plgn1); if (strcmp(scopyright1,ascopyright1)!=0) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } /* PLUGIN INITIALIZE */ ecode = 0; ecode = cpl_plugin_set_init(plgn1, initialize1); if (ecode!=0) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } ainitialize1 = cpl_plugin_get_init(plgn1); if (ainitialize1!=initialize1) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } /* PLUGIN EXECUTE */ ecode = 0; ecode = cpl_plugin_set_exec(plgn1, execute1); if (ecode!=0) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } aexecute1 = cpl_plugin_get_exec(plgn1); if (aexecute1!=execute1) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } /* PLUGIN DEINITIALIZE */ ecode = 0; ecode = cpl_plugin_set_deinit(plgn1, deinitialize1); if (ecode!=0) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } adeinitialize1 = cpl_plugin_get_deinit(plgn1); if (adeinitialize1!=deinitialize1) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } cpl_plugin_delete(plgn1); plgn1 = cpl_plugin_new(); cpl_plugin_init(plgn1, api1, version1, type1, sname1, ssynopsis1, sdescription1, sauthor1, semail1, scopyright1, initialize1, execute1, deinitialize1); if (plgn1==NULL) { cpl_end(); return 1; } /* PLUGIN API */ aapi1 = cpl_plugin_get_api(plgn1); if (aapi1!=api1) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } /* PLUGIN VERSION */ aversion1 = cpl_plugin_get_version(plgn1); if (aversion1!=version1) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } asversion1 = cpl_plugin_get_version_string(plgn1); if (strcmp(sversion1,asversion1)!=0) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } cx_free((char*)asversion1); /* PLUGIN TYPE */ atype1 = cpl_plugin_get_type(plgn1); if (atype1!=type1) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } astype1 = cpl_plugin_get_type_string(plgn1); if (strcmp(stype1,astype1)!=0) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } cx_free((char*)astype1); /* PLUGIN NAME */ asname1 = cpl_plugin_get_name(plgn1); if (strcmp(sname1,asname1)!=0) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } /* PLUGIN SYNOPSIS */ assynopsis1 = cpl_plugin_get_synopsis(plgn1); if (strcmp(ssynopsis1,assynopsis1)!=0) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } /* PLUGIN DESCRIPTION */ asdescription1 = cpl_plugin_get_description(plgn1); if (strcmp(sdescription1,asdescription1)!=0) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } /* PLUGIN AUTHOR */ asauthor1 = cpl_plugin_get_author(plgn1); if (strcmp(sauthor1,asauthor1)!=0) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } /* PLUGIN EMAIL */ asemail1 = cpl_plugin_get_email(plgn1); if (strcmp(semail1,asemail1)!=0) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } /* PLUGIN COPYRIGHT */ ascopyright1 = cpl_plugin_get_copyright(plgn1); if (strcmp(scopyright1,ascopyright1)!=0) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } /* PLUGIN INITIALIZE */ ainitialize1 = cpl_plugin_get_init(plgn1); if (ainitialize1!=initialize1) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } /* PLUGIN EXECUTE */ aexecute1 = cpl_plugin_get_exec(plgn1); if (aexecute1!=execute1) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } /* PLUGIN DEINITIALIZE */ adeinitialize1 = cpl_plugin_get_deinit(plgn1); if (adeinitialize1!=deinitialize1) { cpl_plugin_delete(plgn1); cpl_end(); return 1; } cpl_plugin_delete(plgn1); /* * All tests succeeded */ cpl_end(); return 0; }