1#!/usr/bin/env python3 2# -*- coding: utf-8 -*- 3# Copyright 2020 The ChromiumOS Authors 4# Use of this source code is governed by a BSD-style license that can be 5# found in the LICENSE file. 6 7"""Check to see if the working set produces a good executable. 8 9This test script is made for the noincremental-prune test. This makes sure 10that, after pruning starts (>1 bad item is found), that the number of args sent 11to the switch scripts is equals to the actual number of items (i.e. checking 12that noincremental always holds). 13""" 14 15 16import os 17import sys 18 19from binary_search_tool.test import common 20 21 22def Main(): 23 working_set = common.ReadWorkingSet() 24 25 with open("noinc_prune_good", "r", encoding="utf-8") as good_args: 26 num_good_args = len(good_args.readlines()) 27 28 with open("noinc_prune_bad", "r", encoding="utf-8") as bad_args: 29 num_bad_args = len(bad_args.readlines()) 30 31 num_args = num_good_args + num_bad_args 32 if num_args != len(working_set): 33 print("Only %d args, expected %d" % (num_args, len(working_set))) 34 print("%d good args, %d bad args" % (num_good_args, num_bad_args)) 35 return 3 36 37 os.remove("noinc_prune_bad") 38 os.remove("noinc_prune_good") 39 40 if not os.path.exists("./is_setup"): 41 return 1 42 for w in working_set: 43 if w == 1: 44 return 1 ## False, linking failure 45 return 0 46 47 48if __name__ == "__main__": 49 retval = Main() 50 sys.exit(retval) 51