is_good_noinc_prune.py revision a5e3929d7a155606bc541777fc84e4989389e13c
1#!/usr/bin/python2
2"""Check to see if the working set produces a good executable.
3
4This test script is made for the noincremental-prune test. This makes sure
5that, after pruning starts (>1 bad item is found), that the number of args sent
6to the switch scripts is equals to the actual number of items (i.e. checking
7that noincremental always holds).
8"""
9
10from __future__ import print_function
11
12import os
13import sys
14
15import common
16
17
18def Main():
19  working_set = common.ReadWorkingSet()
20
21  with open('noinc_prune_good', 'r') as good_args:
22    num_good_args = len(good_args.readlines())
23
24  with open('noinc_prune_bad', 'r') as bad_args:
25    num_bad_args = len(bad_args.readlines())
26
27  num_args = num_good_args + num_bad_args
28  if num_args != len(working_set):
29    print('Only %d args, expected %d' % (num_args, len(working_set)))
30    print('%d good args, %d bad args' % (num_good_args, num_bad_args))
31    return 3
32
33  os.remove('noinc_prune_bad')
34  os.remove('noinc_prune_good')
35
36  if not os.path.exists('./is_setup'):
37    return 1
38  for w in working_set:
39    if w == 1:
40      return 1  ## False, linking failure
41  return 0
42
43
44if __name__ == '__main__':
45  retval = Main()
46  sys.exit(retval)
47