3 # A script which generates a template test file using the macros available from
4 # utc_webkit2_ewk.h. The template file is generated in the same directory where this script is located.
7 # ./generate_test_file <function-name> [<number-of-positive-tests>] [<number-of-negative-tests>]
9 # Parameters: <function-name> - the core name of the tested function (e.g., ewk_init)
10 # <number-of-positive-tests> - how many positive tests to generate (default 1)
11 # <number-of-negative-tests> - how many negative tests to generate (default 1)
13 # If you type the following command:
14 # ./generate_test_file ewk_my_favourite_functionality
16 # The script will generate file named 'utc_webkit2_ewk_my_favourite_functionality_func.c'
17 # and will fill its body with template content (1 positive and 1 negative test).
18 # Places to be checked/modified are marked with 'TODO'.
20 # Author: Michal Roj <m.roj@samsung.com>
28 if(@ARGV eq 0) { die("Too few arguments"); }
35 $pos_tests = $ARGV[1];
38 $neg_tests = $ARGV[2];
41 $dirname = dirname(abs_path($script_name));
44 $file_name = "utc_webkit2_${fun_name}_func.c";
46 if(-f $file_name) { die("File $file_name exists!"); }
48 open(OUTFILE, ">${dirname}/${file_name}");
50 # generate generic header
52 $generic_header = <<HEADEND;
56 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
58 * This library is free software; you can redistribute it and/or modify it under
59 * the terms of the GNU Lesser General Public License as published by the
60 * Free Software Foundation; either version 2.1 of the License, or (at your option)
63 * This library is distributed in the hope that it will be useful, but WITHOUT ANY
64 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
65 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
66 * License for more details.
68 * You should have received a copy of the GNU Lesser General Public License
69 * along with this library; if not, write to the Free Software Foundation, Inc., 51
70 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
76 # generate user/test-specific header
78 $user_name = `git config --global --get user.name`;
80 $user_email = `git config --global --get user.email`;
82 ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time);
86 $mon_string = "0${mon}";
88 $mon_string = "${mon}";
92 $mday_string = "0${mday}";
94 $mday_string = "${mday}";
97 $date_string = "${year}-${mon_string}-${mday_string}";
100 $specific_header = <<HEADEND;
103 * \@author $user_name <${user_email}>
104 * \@date ${date_string}
105 * \@brief Tests EWK function ${fun_name}()
110 # generate init section for $pos_tests positive and $neg_tests negative test functions
112 $init_section = <<INITEND;
113 /* Define those macros _before_ you include the utc_webkit2_ewk.h header file. */
114 #define TESTED_FUN_NAME ${fun_name}
115 #define POSITIVE_TEST_FUN_NUM ${pos_tests}
116 #define NEGATIVE_TEST_FUN_NUM ${neg_tests}
118 #include "utc_webkit2_ewk.h"
122 # generate empty positive and empty negative test
124 $template_functions = "";
125 for($i=1; $i<=$pos_tests; $i++) {
127 $template_functions = $template_functions . <<ENDTEMPLATE;
130 * \@brief Tests if (... TODO: add description of this test ...)
134 /* TODO: this code should use ${fun_name} and check its behaviour.
135 Results should be reported using one of utc_ macros */
140 for($i=1; $i<=$neg_tests; $i++) {
142 $template_functions = $template_functions . <<ENDTEMPLATE;
145 * \@brief Tests if (... TODO: add description of this test ...)
149 /* TODO: this code should use ${fun_name} and check its behaviour.
150 Results should be reported using one of utc_ macros */
155 # generate default startup/cleanup functions
157 $startup_cleanup = <<ENDDEFAULT;
158 /* Startup and cleanup functions */
159 static void startup(void)
161 utc_webkit2_ewk_test_init();
164 static void cleanup(void)
166 utc_webkit2_ewk_test_end();
170 print OUTFILE $generic_header, $specific_header, $init_section, $startup_cleanup, $template_functions;
174 print "File ${file_name} with ${pos_tests} positive tests and ${neg_tests} negative tests successfully generated.\n";
175 print "Don't forget adding the generated file to Makefile and tslist.\n";