def generate(self, **kargs): thread_groups = self.queryThreadGroup() if len(thread_groups) != 1: self.error( "Unexpected thread group count; Expected=%d, Actual=%d" % (1, len(thread_groups))) total_thread_count = self.getThreadNumber() thread_constr = ConstraintSet(thread_groups[0][2]) if thread_constr.size() != total_thread_count: self.error( "Unexpected group thread count; Expected=%d, Actual=%d" % (total_thread_count, thread_constr.size())) thread_groups = self.queryThreadGroup(1) if len(thread_groups) != 0: self.error("Unexpectedly retrieved nonexistent thread group %d" % 1) group_id = self.getThreadGroupId() if group_id != 0: self.error("Unexpected thread group ID; Expected=%d, Actual=%d" % (0, group_id)) # The thread count should not be a valid thread ID; e.g. if there are # 16 threads, the largest valid thread ID is 15 group_id = self.getThreadGroupId(total_thread_count) if group_id is not None: self.error("Unexpected thread group ID for nonexistent thread; " "Expected=None, Actual=%d" % group_id) free_threads = self.getFreeThreads() if len(free_threads) != 0: self.error("Unexpected free thread count; Expected=%d, Actual=%d" % (0, len(free_threads)))
def generate(self, **kargs): group_id = self.getThreadGroupId() if group_id == 0: thread_groups = self.queryThreadGroup(0) if len(thread_groups) != 1: self.error( 'Unexpected thread group count; Expected=%d, Actual=%d' % (1, len(thread_groups))) thread_constr = ConstraintSet(thread_groups[0][2]) if thread_constr.size() != 1: self.error( 'Unexpected group thread count; Expected=%d, Actual=%d' % (1, thread_constr.size())) expected_free_thread_count = self.getThreadNumber() - 1 free_threads = self.getFreeThreads() if len(free_threads) != expected_free_thread_count: self.error( 'Unexpected free thread count; Expected=%d, Actual=%d' % (expected_free_thread_count, len(free_threads))) # Allocate two threads into one group randomly self.partitionThreadGroup('Random', group_num=1, group_size=2) expected_free_thread_count -= 2 thread_groups = self.queryThreadGroup() if len(thread_groups) != 2: self.error( 'Unexpected thread group count; Expected=%d, Actual=%d' % (2, len(thread_groups))) thread_constr_0 = ConstraintSet(thread_groups[0][2]) if thread_constr_0.size() != 1: self.error( 'Unexpected group thread count; Expected=%d, Actual=%d' % (1, thread_constr_0.size())) thread_constr_1 = ConstraintSet(thread_groups[1][2]) if thread_constr_1.size() != 2: self.error( 'Unexpected group thread count; Expected=%d, Actual=%d' % (2, thread_constr_1.size())) free_threads = self.getFreeThreads() if len(free_threads) != expected_free_thread_count: self.error( 'Unexpected free thread count; Expected=%d, Actual=%d' % (expected_free_thread_count, len(free_threads))) free_thread_sample = self.sampleFreeThreads(5) group_id = thread_groups[1][0] self.setThreadGroup(group_id, 'Endless Loop', free_thread_sample) expected_free_thread_count = expected_free_thread_count + 2 - 5 thread_groups = self.queryThreadGroup(group_id) if len(thread_groups) != 1: self.error( 'Unexpected thread group count; Expected=%d, Actual=%d' % (1, len(thread_groups))) thread_constr = ConstraintSet(thread_groups[0][2]) if thread_constr.size() != 5: self.error( 'Unexpected group thread count; Expected=%d, Actual=%d' % (5, thread_constr.size())) free_threads = self.getFreeThreads() if len(free_threads) != expected_free_thread_count: self.error( 'Unexpected free thread count; Expected=%d, Actual=%d' % (expected_free_thread_count, len(free_threads)))