~ubuntu-branches/ubuntu/wily/ffc/wily

« back to all changes in this revision

Viewing changes to test/regression/ufctest.py

  • Committer: Package Import Robot
  • Author(s): Johannes Ring
  • Date: 2013-06-26 14:48:32 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20130626144832-1xd8htax4s3utybz
Tags: 1.2.0-1
* New upstream release.
* debian/control:
  - Bump required version for python-ufc, python-fiat, python-instant
    and python-ufl in Depends field.
  - Bump Standards-Version to 3.9.4.
  - Remove DM-Upload-Allowed field.
  - Bump required debhelper version in Build-Depends.
  - Remove cdbs from Build-Depends.
  - Use canonical URIs for Vcs-* fields.
* debian/compat: Bump to compatibility level 9.
* debian/rules: Rewrite for debhelper (drop cdbs).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2010 Anders Logg, Kristian B. Oelgaard and Marie E. Rognes
 
1
# Copyright (C) 2010-2013 Anders Logg, Kristian B. Oelgaard and Marie E. Rognes
2
2
#
3
3
# This file is part of FFC.
4
4
#
15
15
# You should have received a copy of the GNU Lesser General Public License
16
16
# along with FFC. If not, see <http://www.gnu.org/licenses/>.
17
17
#
 
18
# Modified by Martin Alnaes, 2013
 
19
#
18
20
# First added:  2010-01-24
19
 
# Last changed: 2011-07-08
 
21
# Last changed: 2013-02-14
20
22
 
21
23
_test_code = """\
22
24
#include "../../ufctest.h"
23
25
#include "%s.h"
 
26
#include <fstream>
24
27
 
25
 
int main()
 
28
int main(int argc, char * argv[])
26
29
{
27
 
%s
28
 
 
 
30
  const char jsonfilename[] = "%s.json";
 
31
  std::ofstream jsonfile(jsonfilename);
 
32
  Printer printer(std::cout, jsonfile);
 
33
  printer.begin();
 
34
 
 
35
%s%s
 
36
 
 
37
  printer.end();
29
38
  return 0;
30
39
}
31
40
"""
32
41
 
33
 
def generate_test_code(header_file, bench):
 
42
def generate_test_code(header_file):
34
43
    "Generate test code for given header file."
35
44
 
36
45
    # Count the number of forms and elements
41
50
 
42
51
    # Generate tests, either based on forms or elements
43
52
    if num_forms > 0:
44
 
        tests = ["  %s_form_%d f%d; test_form(f%d, %d);" % (prefix.lower(), i, i, i, bench) for i in range(num_forms)]
 
53
        benchline = "  bool bench = (argc > 1) && argv[1][0] == 'b';\n"
 
54
        tests = ['  %s_form_%d f%d; test_form(f%d, bench, %d, printer);' % (prefix.lower(), i, i, i, i)
 
55
                 for i in range(num_forms)]
45
56
    else:
46
 
        tests = ["  %s_finite_element_%d e%d; test_finite_element(e%d);" % (prefix.lower(), i, i, i) for i in range(num_elements)]
 
57
        benchline = ""
 
58
        tests = ['  %s_finite_element_%d e%d; test_finite_element(e%d, %d, printer);' % (prefix.lower(), i, i, i, i)
 
59
                 for i in range(num_elements)]
47
60
 
48
61
    # Write file
49
62
    test_file = open(prefix + ".cpp", "w")
50
 
    test_file.write(_test_code % (prefix, "\n".join(tests)))
 
63
    test_file.write(_test_code % (prefix, prefix, benchline, "\n".join(tests)))
51
64
    test_file.close()
 
65