[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21403] branches/soc-2009-kazanbas: Forgot to add files containing test code.
Arystanbek Dyussenov
arystan.d at gmail.com
Tue Jul 7 10:44:21 CEST 2009
Revision: 21403
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21403
Author: kazanbas
Date: 2009-07-07 10:44:21 +0200 (Tue, 07 Jul 2009)
Log Message:
-----------
Forgot to add files containing test code.
Added Paths:
-----------
branches/soc-2009-kazanbas/tests/
branches/soc-2009-kazanbas/tests/SConscript
branches/soc-2009-kazanbas/tests/alltest.c
Added: branches/soc-2009-kazanbas/tests/SConscript
===================================================================
--- branches/soc-2009-kazanbas/tests/SConscript (rev 0)
+++ branches/soc-2009-kazanbas/tests/SConscript 2009-07-07 08:44:21 UTC (rev 21403)
@@ -0,0 +1,138 @@
+#!/usr/bin/env python
+import os
+
+Import('env')
+Import('build_data')
+
+test_env = env.Clone()
+test_env.Append(CPPPATH=['#source/blender/blenkernel',
+ '#source/blender/blenlib',
+ '#source/blender/makesdna',
+ '#intern/guardedalloc'])
+test_env.Append(LIBPATH=["../lib"] + build_data["libpath"])
+
+if test_env['OURPLATFORM']=='linux2':
+
+ test_env.Append(LINKFLAGS=test_env['PLATFORM_LINKFLAGS'])
+
+ if test_env['WITH_BF_PYTHON']:
+ test_env.Append(LINKFLAGS=test_env['BF_PYTHON_LINKFLAGS'])
+
+ if test_env['BF_DEBUG']:
+ test_env.Append(CFLAGS=test_env['BF_DEBUG_CFLAGS'])
+ test_env.Append(CCFLAGS=test_env['BF_DEBUG_CCFLAGS'])
+ test_env.Append(CXXFLAGS=test_env['BF_DEBUG_CXXFLAGS'])
+
+ # Pass --start-group to linker to solve circular dependencies in blender libs.
+ # This is for GCC only.
+ test_env.Append(LINKFLAGS=['-Wl,--start-group'])
+
+lib = ['bf_readblenfile',
+# 'bf_creator',
+ 'extern_libavformat',
+ 'extern_libavcodec',
+ 'extern_libswscale',
+ 'extern_libavutil',
+ 'extern_libavdevice',
+ 'bf_decimation',
+ 'extern_x264',
+ 'extern_libmp3lame',
+ 'extern_xvidcore',
+ 'bf_windowmanager',
+ 'blender_BSP',
+ 'bf_editors_space_api',
+ 'bf_editors_object',
+ 'bf_editors_space_image',
+ 'bf_editors_space_view3d',
+ 'bf_editors_transform',
+ 'bf_editors_sculpt_paint',
+ 'bf_editors_armature',
+ 'bf_editors_mesh',
+ 'bf_editors_curve',
+ 'bf_editors_gpencil',
+ 'bf_editors_physics',
+ 'bf_editors_preview',
+ 'bf_editors_space_graph',
+ 'bf_editors_uvedit',
+ 'blender_ONL',
+ 'bf_editors_space_node',
+ 'bf_editors_space_outliner',
+ 'bf_editors_space_time',
+ 'bf_editors_space_info',
+ 'bf_editors_space_sound',
+ 'bf_editors_space_action',
+ 'bf_editors_space_nla',
+ 'bf_editors_space_script',
+ 'bf_editors_space_text',
+ 'bf_editors_space_sequencer',
+ 'bf_editors_screen',
+ 'bf_editors_interface',
+ 'bf_editors_space_file',
+ 'bf_editors_space_buttons',
+ 'bf_editors_space_game',
+ 'bf_editors_animation',
+ 'bf_editors_util',
+ 'bf_blenloader',
+ 'bf_editor_datafiles',
+ 'bf_python',
+ 'bf_render',
+ 'bf_gpu',
+ 'bf_blenkernel',
+ 'bf_blenpluginapi',
+ 'bf_cmpnodes',
+ 'bf_shdnodes',
+ 'bf_texnodes',
+ 'bf_blenlib',
+ 'bf_avi',
+ 'bf_imbuf',
+ 'bf_nodes',
+ 'bf_rna',
+ 'bf_blenfont',
+ 'bf_dna',
+ 'bf_cineon',
+ 'bf_openexr',
+ 'bf_dds',
+ 'bf_gen_python',
+ 'bf_kernel',
+ 'bf_memutil',
+ 'bf_elbeem',
+ 'bf_guardedalloc',
+ 'blender_bop',
+ 'extern_libavformat',
+ 'extern_libavcodec',
+ 'extern_libswscale',
+ 'blender_CTR',
+ 'extern_x264',
+ 'extern_libmp3lame',
+ 'extern_xvidcore',
+ 'extern_libavutil',
+ 'extern_libavdevice',
+ 'bf_soundsystem',
+ 'bf_ghost',
+ 'bf_string',
+ 'bf_IK',
+ 'bf_moto',
+ 'extern_openjpeg',
+ 'extern_bullet2softbody',
+ 'extern_bullet2dynamics',
+ 'extern_bullet2linmath',
+ 'extern_bullet2collision_dispatch',
+ 'extern_bullet2collision_gimpact',
+ 'extern_bullet2collision_shapes',
+ 'extern_bullet2collision_narrowphase',
+ 'extern_bullet2collision_broadphase',
+ 'extern_binreloc',
+ 'extern_glew'] + build_data["lib"] + ['check']
+
+alltest = None
+if env['WITH_BF_UNIT_TEST']:
+
+ alltest = test_env.Program(target='../bin/alltest', source='alltest.c', LIBS=lib)
+
+ # Tell scons Blender depends on test program, otherwise it won't build.
+ test_env.Depends(build_data["blen"], alltest)
+
+# # to run tests
+# test_env.Command(source_files, ?, ?)
+
+Return('alltest')
Added: branches/soc-2009-kazanbas/tests/alltest.c
===================================================================
--- branches/soc-2009-kazanbas/tests/alltest.c (rev 0)
+++ branches/soc-2009-kazanbas/tests/alltest.c 2009-07-07 08:44:21 UTC (rev 21403)
@@ -0,0 +1,142 @@
+#include <stdlib.h>
+#include <string.h>
+#include <check.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "BKE_blender.h"
+#include "BKE_image.h"
+#include "BKE_utildefines.h"
+#include "BKE_global.h"
+
+#include "BLI_listbase.h"
+
+#include "DNA_image_types.h"
+
+char bprogname[FILE_MAXDIR+FILE_MAXFILE];
+char btempdir[FILE_MAXDIR+FILE_MAXFILE];
+
+typedef struct StringPair {
+ char *first;
+ char *second;
+} StringPair;
+
+/* check that BKE_copy_images correctly manipulates paths */
+START_TEST(test_copy_images)
+{
+ char *dest_dir = "/tmp/";
+ ListBase *lim;
+ ListBase *lfi;
+ Image images[100];
+ StringPair *pair;
+ int i;
+ int j;
+ LinkData *link;
+
+ lim= MEM_callocN(sizeof(*lim), "ListBase");
+
+ memset(images, 0, sizeof(images));
+
+ /* XXX Windows not tested */
+#ifdef WIN32
+ BLI_strncpy(G.sce, "C:\\Temp\untitled.blend", sizeof(G.sce));
+
+ static StringPair pairs[] = {
+ {"//bar/image.png", "C:\\Temp\\bar\\image.png"},
+ /* TODO add more */
+ {NULL, NULL},
+ };
+#else
+ /* substitute G.sce */
+ BLI_strncpy(G.sce, "/tmp/untitled.blend", sizeof(G.sce));
+
+ /*
+ XXX are these paths possible in image->name?:
+
+ ./foo/image.png
+ ../foo/image.png
+
+ if so, BKE_copy_images currently doesn't support them!
+ */
+ static StringPair pairs[] = {
+ {"//bar/image.png", "/tmp/bar/image.png"},
+ {"/foo/bar/image.png", "/tmp/image.png"},
+ {"//image.png", "/tmp/image.png"},
+ {"//../../../foo/bar/image.png", "/tmp/image.png"},
+ {"//./foo/bar/image.png", "/tmp/foo/bar/image.png"},
+ {"/tmp/image.png", "/tmp/image.png"},
+ {"//textures/test/foo/bar/image.png", "/tmp/textures/test/foo/bar/image.png"},
+ {NULL, NULL},
+ };
+#endif
+
+ /* create "fake" images with initting only the name member */
+ for (i= 0, pair= &pairs[0]; pair->first; pair++) {
+ Image *im = &images[i++];
+ BLI_strncpy(im->name, pair->first, sizeof(im->name));
+
+ link= MEM_callocN(sizeof(*link), "LinkData");
+ link->data= im;
+
+ BLI_addtail(lim, link);
+ }
+
+ lfi= MEM_callocN(sizeof(*lfi), "ListBase");
+
+ BKE_copy_images(lim, dest_dir, lfi);
+
+ i= BLI_countlist(lfi);
+ j= sizeof(pairs)/sizeof(StringPair) - 1;
+ fail_if(i != j, "Number of filenames, %d, doesn't match number of images, %d.", i, j);
+
+ /* check that output is correct */
+ for (link= lfi->first, pair= &pairs[0]; link; link= link->next, pair++) {
+ char *path= link->data;
+
+ /* fail if output doesn't match expected output */
+ fail_if(strcmp(path, pair->second), "Expected %s to be translated to %s, got %s.", pair->first, pair->second, path);
+
+ if (path)
+ MEM_freeN(path);
+ }
+
+ BLI_freelistN(lim);
+ BLI_freelistN(lfi);
+}
+END_TEST
+
+Suite *image_suite(void)
+{
+ Suite *s = suite_create("Image");
+
+ /* Core test case */
+ TCase *tc_core = tcase_create("Core");
+ tcase_add_test(tc_core, test_copy_images);
+ suite_add_tcase(s, tc_core);
+
+ return s;
+}
+
+/* probably will need other calls as new tests are added */
+void init_blender(int argc, char **argv)
+{
+ BLI_where_am_i(bprogname, argv[0]);
+ BLI_where_is_temp(btempdir, 1);
+}
+
+int main(int argc, char **argv)
+{
+ int totfail;
+ Suite *s = image_suite();
+ SRunner *sr = srunner_create(s);
+
+ init_blender(argc, argv);
+
+ /* run tests */
+ srunner_run_all(sr, CK_VERBOSE);
+
+ totfail= srunner_ntests_failed(sr);
+ srunner_free(sr);
+
+ return !totfail ? EXIT_SUCCESS : EXIT_FAILURE;
+}
More information about the Bf-blender-cvs
mailing list