ut_interp.c

00001 /*
00002 # This file is Copyright 2003, 2006, 2007, 2009 Dean Hall.
00003 #
00004 # This file is part of the Python-on-a-Chip program.
00005 # Python-on-a-Chip is free software: you can redistribute it and/or modify
00006 # it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1.
00007 #
00008 # Python-on-a-Chip is distributed in the hope that it will be useful,
00009 # but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00011 # A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1
00012 # is seen in the file COPYING up one directory from this.
00013 */
00014 
00015 
00022 #include "CuTest.h"
00023 #include "pm.h"
00024 
00025 
00026 /* BEGIN unit tests ported from Snarf */
00055 extern uint8_t test_code_image0[];
00056 
00057 
00062 void
00063 ut_interp_interpret_000(CuTest *tc)
00064 {
00065     PmReturn_t retval;
00066     uint8_t const *pimg = test_code_image0;
00067     pPmObj_t pcodeobject;
00068     pPmObj_t pmodule;
00069 
00070     pm_init(MEMSPACE_RAM, C_NULL);
00071 
00072     /* Check the return value of the load function */
00073     retval = obj_loadFromImg(MEMSPACE_PROG, &pimg, &pcodeobject);
00074     CuAssertTrue(tc, retval == PM_RET_OK);
00075     retval = mod_new(pcodeobject, &pmodule);
00076     CuAssertTrue(tc, retval == PM_RET_OK);
00077     retval = interp_addThread((pPmFunc_t)pmodule);
00078     CuAssertTrue(tc, retval == PM_RET_OK);
00079 
00080     /* Check that the module is interpreted and its return value is ok */
00081     retval = interpret(C_TRUE);
00082     CuAssertTrue(tc, retval == PM_RET_OK);
00083 }
00084 /* END unit tests ported from Snarf */
00085 
00086 
00088 CuSuite *getSuite_testInterp(void)
00089 {
00090     CuSuite* suite = CuSuiteNew();
00091 
00092     SUITE_ADD_TEST(suite, ut_interp_interpret_000);
00093 
00094     return suite;
00095 }

Generated on Mon Oct 18 07:40:47 2010 for Python-on-a-chip by  doxygen 1.5.9