]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/tools/build/test/sort_rule.py
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / tools / build / test / sort_rule.py
1 #!/usr/bin/python
2
3 # Copyright (C) 2008. Jurko Gospodnetic
4 # Distributed under the Boost Software License, Version 1.0.
5 # (See accompanying file LICENSE.txt or copy at
6 # https://www.bfgroup.xyz/b2/LICENSE.txt)
7
8 # Tests for the Boost Jam builtin SORT rule.
9
10 from __future__ import print_function
11
12 import BoostBuild
13
14
15 ###############################################################################
16 #
17 # testSORTCorrectness()
18 # ---------------------
19 #
20 ###############################################################################
21
22 def testSORTCorrectness():
23 """Testing that Boost Jam's SORT builtin rule actually sorts correctly."""
24 t = BoostBuild.Tester(["-ftest.jam", "-d1"], pass_toolset=False,
25 use_test_config=False)
26
27 t.write("test.jam", """\
28 NOCARE all ;
29 source-data = 1 8 9 2 7 3 4 7 1 27 27 9 98 98 1 1 4 5 6 2 3 4 8 1 -2 -2 0 0 0 ;
30 target-data = -2 -2 0 0 0 1 1 1 1 1 2 2 27 27 3 3 4 4 4 5 6 7 7 8 8 9 9 98 98 ;
31 ECHO "starting up" ;
32 sorted-data = [ SORT $(source-data) ] ;
33 ECHO "done" ;
34 if $(sorted-data) != $(target-data)
35 {
36 ECHO "Source :" $(source-data) ;
37 ECHO "Expected :" $(target-data) ;
38 ECHO "SORT returned:" $(sorted-data) ;
39 EXIT "SORT error" : -2 ;
40 }
41 """)
42
43 t.run_build_system()
44 t.expect_output_lines("starting up")
45 t.expect_output_lines("done")
46 t.expect_output_lines("SORT error", False)
47
48 t.cleanup()
49
50
51 ###############################################################################
52 #
53 # testSORTDuration()
54 # ------------------
55 #
56 ###############################################################################
57
58 def testSORTDuration():
59 """
60 Regression test making sure Boost Jam's SORT builtin rule does not get
61 quadratic behaviour again in this use case.
62
63 """
64 t = BoostBuild.Tester(["-ftest.jam", "-d1"], pass_toolset=False,
65 use_test_config=False)
66
67 f = open(t.workpath("test.jam"), "w")
68 print("data = ", file=f)
69 for i in range(0, 20000):
70 if i % 2:
71 print('"aaa"', file=f)
72 else:
73 print('"bbb"', file=f)
74 print(""";
75
76 ECHO "starting up" ;
77 sorted = [ SORT $(data) ] ;
78 ECHO "done" ;
79 NOCARE all ;
80 """, file=f)
81 f.close()
82
83 t.run_build_system(expected_duration=1)
84 t.expect_output_lines("starting up")
85 t.expect_output_lines("done")
86
87 t.cleanup()
88
89
90 ###############################################################################
91 #
92 # main()
93 # ------
94 #
95 ###############################################################################
96
97 testSORTCorrectness()
98 testSORTDuration()