Exemple #1
0
def main():
    """comparison_test script entry point"""

    parser = argparse.ArgumentParser(
        description='vcdMaker tools comparison testing utility')
    parser.add_argument('--exec',
                        '-e',
                        required=True,
                        help="Path to the vcdMaker executable")
    parser.add_argument('--testdir',
                        '-t',
                        required=True,
                        help="Path to the directory containing tests")
    parser.add_argument('--verbose',
                        '-v',
                        action='store_true',
                        default=False,
                        help="Turns on verbose output")
    args = parser.parse_args()

    check_arguments(args)

    tests = Tests(args.testdir)
    executor = Executor(args.exec, tests.get_tests(), args.verbose)

    result, number_failed, number_total = executor.run()

    if not result:
        print('TEST PASSED ({})'.format(number_total))
        exit_result = 0
    else:
        print('TEST FAILED ({}/{})'.format(number_failed, number_total))
        exit_result = 1

    sys.exit(exit_result)
Exemple #2
0
 def __init__(self):
     self.read_data = ReadData()
     self.naive = Naive()
     self.branch_and_bound = Branch_And_Bound()
     self.tests = Tests()
     self.data = []
     self.choice = 0
     self.starting_city = 0
Exemple #3
0
    def __init__(self, parent):
        View.__init__(self, parent)
        self._devices = TestDeviceList(self._elements["treeWidgetDevices"])

        self._actionStart = self._elements["actionStart"]
        self._actionStop = self._elements["actionStop"]
        self._actionPause = self._elements["actionPause"]
        self._actionResume = self._elements["actionResume"]

        self._actionStart.triggered.connect(self._startTests)
        self._actionStop.triggered.connect(self._stopTests)
        self._actionPause.triggered.connect(self._pauseTests)
        self._actionResume.triggered.connect(self._resumeTests)

        self._actionStart.setVisible(True)
        self._actionStop.setVisible(False)
        self._actionPause.setVisible(False)
        self._actionResume.setVisible(False)

        # Summary channel
        channels.add("SummaryChannel", "_ui_summary")

        # Progress channel
        pBar = QtGui.QProgressBar()
        pBar.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter)
        font = pBar.font()
        font.setBold(True)
        pBar.setFont(font)
        self._parent.getStatusBar().addPermanentWidget(pBar, 1)
        self._progress = ProgressChannelHelper(pBar)
        channels.add(ProgressChannel, "_ui_progress", progress=self._progress)
        self._progress.testStarted.connect(self._onTestStarted)
        self._progress.testStopped.connect(self._onTestStopped)
        self._progress.stopped.connect(self._onStopped)

        self._tests = Tests(self._elements["treeWidgetLocations"],
                            self._elements["treeWidgetTests"],
                            self._elements["treeWidgetModels"])

        self._elements["actionAdd"].triggered.connect(self._tests.addLocation)
        self._elements["actionRemove"].triggered.connect(
            self._tests.removeLocation)
        self._elements["actionExpand"].triggered.connect(
            self._tests.expandSelected)
        self._elements["actionExpandAll"].triggered.connect(
            self._tests.expandAll)
        self._elements["actionCollapse"].triggered.connect(
            self._tests.collapseSelected)
        self._elements["actionCollapseAll"].triggered.connect(
            self._tests.collapseAll)
        self._elements["actionRefresh"].triggered.connect(self._tests.refresh)

        # Initialize private test variables
        self._suiteRuns = 0
        self._todoSuites = 0
        self._testResult = None
        self._testRunner = None
Exemple #4
0
    def build(self):

        sm = ScreenManager()
        sm.add_widget(Login(name='login'))
        sm.add_widget(MainMenu(name='main_menu'))
        sm.add_widget(Profile(name='profile'))
        sm.add_widget(Results(name='results'))
        sm.add_widget(Tests(name='tests'))

        return sm
Exemple #5
0
    def start_tests(self):
        test_num = 1
        for test in self.__test_list:
            logger = get_logger(test_num)
            list_flows = []
            test_obj = Tests(self.__w3, logger, self.__inspector)
            try:
                func_args = test["args"]

                if test_obj.is_thread(test["func"]):
                    list_flows = []
                    flows = test["flows"]
                    if flows > len(self.accounts):
                        flows = len(self.accounts)

                    for i in range(flows):
                        j = i + 1
                        if j == len(self.accounts):
                            j = 0
                        accounts = (self.accounts[i][0], self.accounts[i][1],
                                    self.accounts[j][0], self.accounts[j][1])
                        func_args.insert(0, accounts)
                        list_flows.append(
                            Thread(target=test_obj.start_test,
                                   args=(test["func"], func_args.copy())))
                        func_args.pop(0)
                else:
                    list_flows.append(
                        Thread(target=test_obj.start_test,
                               args=(test["func"], func_args.copy())))

                logger.info("Start test {0}(flows: {3}): {1}{2}".format(
                    test_num, test["func"], test["args"], len(list_flows)))

                for flow in list_flows:
                    flow.start()
                while True:
                    list_alive = [
                        state.is_alive() for state in list_flows
                        if state.is_alive()
                    ]
                    if not list_alive:
                        break

            except TypeError as e:
                logger.error("\tUnhandled error in starting {2}:{0}{1}".format(
                    e.__class__.__name__, e, test["func"]))

                continue

            finally:
                test_num += 1
                sleep(
                    5
                )  # There are cases when transactions in same tests do not have time to process on the node
Exemple #6
0
    def run_fufu(self):
        os.system("cls")
        self.result_table = []
        ''' get ssh connection and reset eth0 ip address '''
        self.utils = Utils(self)
        if self.utils.ssh is None:
            self.result_table.append(['Connection to the system', 'FAIL'])
            print("Can't established ssh connection")
            raw_input('Press Enter for continue...')
            self.menu()
        else:
            self.result_table.append(['Connection to the system', 'PASS'])

        tests = Tests(self, self.utils)

        if not tests.check_bands():
            self.menu()

        print('Enable Remote and Modem Communication: {}'.format(
            self.utils.set_remote_communication(1)))
        ''' save set files '''
        self.utils.send_command('udp_bridge1', 'start')
        storm = Storm(self)
        for place, band in enumerate(self.utils.get_bands()):
            storm.save_setfile(place=place, band=band)
        self.result_table.append(['Save set file for IDOBR', 'PASS'])
        self.utils.send_command('udp_bridge1', 'stop')

        self.utils.set_filters(1)

        tests.verify_connections()
        ''' test power '''
        tests.test_composite_power()
        ''' test bands status '''
        tests.test_band_status()
        ''' test sw and patch version '''
        tests.test_swv()
        ''' Set date and time'''
        tests.set_dateTime()
        ''' TTF calibration '''
        tests.ttf_calibrate()
        ''' Band mute test '''
        tests.mute_test()
        ''' test alarm '''
        tests.test_ext_alarm()
        ''' gps/gpr test '''
        tests.gpr_gps_test()
        ''' clear log '''
        tests.clear_log()
        self.utils.print_table(['Description', 'Status'], self.result_table)
        self.utils.ssh.close()
        raw_input('Press Enter for continue...')
        self.menu()
Exemple #7
0
    def handle_mrregs(self, mr):
        if not self.factory.requester:
            if self.factory.verbosity:
                print('Ignoring mrregs - not requester')
            return
        for v in mr:
            req = v[0]
            if req['__class__'] != 'req_MR_REG':
                print('Error: expected req_MR_REG, got {}'.format(
                    req['__class__']))
                continue
            access = req['__value__']['access']
            sz = req['__value__']['len']
            rsp = v[1]
            if rsp['__class__'] != 'rsp_MR_REG':
                print('Error: expected rsp_MR_REG, got {}'.format(
                    rsp['__class__']))
                continue
            rsp_zaddr = rsp['__value__']['rsp_zaddr']
            put_get_remote = MR.PUT_REMOTE | MR.GET_REMOTE
            test_remote = ((access & put_get_remote) == put_get_remote)
            if self.factory.load_store:
                access |= MR.REQ_CPU
            print('mr: rsp_zaddr={:#x}, sz={:#x}, access={:#x}'.format(
                rsp_zaddr, sz, access))

            if test_remote:
                conn = self.factory.conn
                rmr = conn.do_RMR_IMPORT(self.remote_nodeid, rsp_zaddr, sz,
                                         access)
                pg_sz = 1 << rmr.pg_ps
                mask = (-pg_sz) & ((1 << 64) - 1)
                mmsz = (sz + (pg_sz - 1)) & mask
                pg_off = rmr.req_addr & ~mask
                if self.factory.load_store:
                    rmm = mmap.mmap(conn.fno, mmsz, offset=rmr.offset)
                else:
                    rmm = None
                t = Tests(self.factory.lmr, self.factory.lmm, rmr, sz, rmm,
                          self.factory.xdm, self.factory.verbosity,
                          self.factory.load_store, self.factory.physaddr)
                t.all_tests()
            else:
                print('skipping tests because mr not remote put/get')
Exemple #8
0
def main():

    urlBase = '127.0.0.1'
    port = 8080

    url = None
    for testing in ROUTINE:
        verb = testing.get('verb')
        pathUri = testing.get('path')
        method = testing.get('method')
        headers = testing.get('headers')
        body = testing.get('body')

        test = Tests(urlBase=urlBase,
                     port=port,
                     pathUri=pathUri,
                     method=method,
                     headers=headers,
                     body=body,
                     verb=verb)
        response = test.call()
        #print(response.code)
        #print(response.headers)
        #print(response.reason)
        #print(response.read().decode('utf-8'))
        # self.dictionary = self.response.read().decode('utf-8')
        # return json.loads(self.dictionary)
        if (url == None or url != pathUri + method):
            url = pathUri + method
            print(Color.SUCCESS_BLUE + url + Color.NORMAL)

        if (response.code == testing.get('return_code')):
            print(Color.SUCCESS_GREEN + '[OK] ' +
                  str(testing.get('return_code')) + ' >> ' +
                  testing.get('description') + Color.NORMAL)
        else:
            print(Color.FAIL + '[FAIL] ' + str(testing.get('return_code')) +
                  ' >> ' + testing.get('description') + Color.NORMAL)
Exemple #9
0
def main():
    py.init()
    screen = py.display.set_mode((WIDTH, HEIGHT))
    py.display.set_caption(TITLE)

    cc = (0, 0, 0)
    exit = False
    FPS = py.time.Clock()
    dt = 0

    tests = Tests()

    while not exit:
        for event in py.event.get():
            if event.type == py.QUIT:
                exit = True

        screen.fill(cc)

        tests.update(dt)
        tests.render(screen)
        py.display.update()
        dt = FPS.tick(60)
    py.quit()
Exemple #10
0
if args.cuda:
    model_target.cuda()
    model_source.cuda()
    discriminator_model.cuda()

# target_optimizer_encoder_params = [{'params': model_target.fc1.parameters()}, {'params': model_target.fc2.parameters()}]
target_optimizer = optim.Adam(model_target.parameters(), lr=args.lr)
# target_optimizer_encoder = optim.Adam(target_optimizer_encoder_params, lr=args.lr)
source_optimizer = optim.Adam(model_source.parameters(), lr=args.lr)
d_optimizer = optim.Adam(discriminator_model.parameters(), lr=args.lr)

criterion = nn.BCELoss()

if args.source == 'mnist':
    tests = Tests(model_source, model_target, classifyMNIST, 'mnist',
                  'fashionMnist', args, graph)
elif args.source == 'fashionMnist':
    tests = Tests(model_source, model_target, classifyMNIST, 'fashionMnist',
                  'mnist', args, graph)
else:
    raise Exception('args.source does not defined')


def reset_grads():
    model_target.zero_grad()
    model_source.zero_grad()
    discriminator_model.zero_grad()


def gen(model, input_data, optimizer, loss, batch):
    reset_grads()
Exemple #11
0
    with cd('results'):
        if not os.path.exists('data'):
            os.makedirs('data')
        with cd('data'):
            if not os.path.exists('Experiment-' + str(experiment_number)):
                os.makedirs('Experiment-' + str(experiment_number))

    logger = setup_logger('results/data/Experiment-' + str(experiment_number), "__main__", "main")
    logger.info("###################################RUNNING EXPERIMENT NUM %s#########################", str(experiment_number))
    logger.info("Program Arguments:")
    args_dict = vars(args)
    for key, value in args_dict.iteritems() :
        logger.info("%s=%s" % (str(key), str(value)))

    test_suite = Tests(logger, args)
    target_test, Y_pred, cost_list, cost_test_list, learning_rates, rmse = test_suite.run_tests()

    Y_pred_copy = np.copy(Y_pred)
    accuracy_score_Y_pred =  np.rint(Y_pred_copy).astype(int)

    if args.test_type != 'f':
        logger.info('###################################Accuracy Results###############################')
        logger.info('Accuracy: ' + str(accuracy_score(target_test, accuracy_score_Y_pred)))
        logger.info('\n' + str(classification_report(target_test, accuracy_score_Y_pred)))
    else:
        logger.info('###################################Accuracy Results###############################')

        target_test_1d = target_test.ravel()
        Y_pred_1d = Y_pred.ravel()
        distance = 0
Exemple #12
0
 def corrigeFromModules(self, team, modules, classes):
     # if team.noTeam == 15:
     #     return 0
     note = 0
     print_barre()
     print_equipe(team.noTeam)
     comment = "<h2>Évaluation du critère 3</h2>"
     comment += "<h3>Fonctionnement général</h3>"
     test = Tests(team, modules, classes)
     if test.equipeOk:
         # FAIRE TOUT LES TESTS
         test.loadClassObject()
         comment += "<h3>Fonctionnement MarchéBoursier</h3>"
         print_titre("Prix")
         comment += "<h4>Vérification de la méthode prix</h4><ul>"
         res = test.test_2_prix()
         if res[0]:
             note += 1
         comment += res[1]
         comment += "<h3>Fonctionnement Portefeuille Date: 2019-03-28</h3>"
         print_titre("Déposer")
         comment += "</ul><h4>Vérification de la méthode déposer</h4><ul>"
         res = test.test_4_deposer()
         if res[0]:
             note += 1
         comment += res[1]
         print_titre("Solde")
         comment += "</ul><h4>Vérification de la méthode solde</h4><ul>"
         res = test.test_6_solde()
         if res[0]:
             note += 1
         comment += res[1]
         print_titre("Acheter")
         comment += "</ul><h4>Vérification de la méthode acheter</h4><ul>"
         res = test.test_9_acheter()
         if res[0]:
             note += 1
         comment += res[1]
         print_titre("Vendre")
         comment += "</ul><h4>Vérification de la méthode vendre</h4><ul>"
         res = test.test_11_vendre()
         if res[0]:
             note += 1
         comment += res[1]
         print_titre("Valeur totale")
         comment += "</ul><h4>Vérification de la méthode valeur totale</h4><ul>"
         res = test.test_13_valeur_totale()
         if res[0]:
             note += 1
         comment += res[1]
         res = test.test_16_valeur_des_titres()
         if res[0]:
             note += 1
         comment += res[1]
         print_titre("Titre")
         comment += "</ul><h4>Vérification de la méthode titre</h4><ul>"
         res = test.test_18_titres()
         if res[0]:
             note += 1
         comment += res[1]
         print_titre("Valeur projetée")
         comment += "</ul><h4>Vérification de la méthode valeur projetée</h4><ul>"
         res = test.test_19_valeur_projetee()
         if res[0]:
             note += 1
         comment += res[1]
         test.loadClassObject()
         comment += "<h3>Fonctionnement Portefeuille Date: Par défaut</h3><p>Notez que le portefeuille à été réinitialisé complètement</p>"
         print_titre("Déposer")
         comment += "</ul><h4>Vérification de la méthode déposer</h4><ul>"
         res = test.test_3_deposer()
         if res[0]:
             note += 1
         comment += res[1]
         print_titre("Solde")
         comment += "</ul><h4>Vérification de la méthode solde</h4><ul>"
         res = test.test_5_solde()
         if res[0]:
             note += 1
         comment += res[1]
         print_titre("Acheter")
         comment += "</ul><h4>Vérification de la méthode acheter</h4><ul>"
         res = test.test_7_acheter()
         if res[0]:
             note += 1
         comment += res[1]
         res = test.test_8_acheter()
         if res[0]:
             note += 1
         comment += res[1]
         print_titre("Vendre")
         comment += "</ul><h4>Vérification de la méthode vendre</h4><ul>"
         res = test.test_10_vendre()
         if res[0]:
             note += 1
         comment += res[1]
         print_titre("Valeur totale")
         comment += "</ul><h4>Vérification de la méthode valeur totale</h4><ul>"
         res = test.test_12_valeur_totale()
         if res[0]:
             note += 1
         comment += res[1]
         print_titre("Valeur des titres")
         comment += "</ul><h4>Vérification de la méthode valeur des titres</h4><ul>"
         res = test.test_14_valeur_des_titres()
         if res[0]:
             note += 1
         comment += res[1]
         res = test.test_15_valeur_des_titres()
         if res[0]:
             note += 1
         comment += res[1]
         print_titre("Titre")
         comment += "</ul><h4>Vérification de la méthode titre</h4><ul>"
         res = test.test_17_titres()
         if res[0]:
             note += 1
         comment += res[1]
         print_titre("Valeur projetée")
         comment += "</ul><h4>Vérification de la méthode valeur projetée</h4><ul>"
         res = test.test_20_valeur_projetee()
         if res[0]:
             note += 1
         comment += res[1]
         # FIN DE TESTS
         print_note(note, 19)
         note_temp = note
         # test.cleanUp()
         test.loadClassObject()
         print_titre("LiquiditéInsuffisante")
         comment += "</ul><h4>Vérification de l'erreur LiquiditéInsuffisante</h4><ul>"
         test.erreur_0_1_depot()
         res = test.erreur_0_liquid_acheter()
         if res[0]:
             note += 1
         comment += res[1]
         print_titre("ErreurDate")
         comment += "</ul><h4>Vérification de l'erreur ErreurDate</h4><ul>"
         res = test.erreur_1_date_prix()
         if res[0]:
             note += 1
         comment += res[1]
         res = test.erreur_2_date_déposer()
         if res[0]:
             note += 1
         comment += res[1]
         res = test.erreur_3_date_solde()
         if res[0]:
             note += 1
         comment += res[1]
         res = test.erreur_4_date_acheter()
         if res[0]:
             note += 1
         comment += res[1]
         test.erreur_4_1_depot()
         test.erreur_4_2_achat()
         res = test.erreur_5_date_vendre()
         if res[0]:
             note += 1
         comment += res[1]
         res = test.erreur_6_date_valeur_totale()
         if res[0]:
             note += 1
         comment += res[1]
         res = test.erreur_7_date_valeur_titres()
         if res[0]:
             note += 1
         comment += res[1]
         res = test.erreur_8_date_titres()
         if res[0]:
             note += 1
         comment += res[1]
         print_titre("ErreurQuantité")
         comment += "</ul><h4>Vérification de l'erreur ErreurQuantité</h4><ul>"
         res = test.erreur_9_quantite_vendre()
         if res[0]:
             note += 1
         comment += res[1]
         comment += "</ul>"
         print_note(note-note_temp, 10)
         note = round(note*100/29, 1)
         print_final(3, note, 100)
         test.cleanUp()
     else:
         print_warning(f"  FAIL : Programme non fonctionnel 1")
         comment += "<p>Votre code n'est pas fonctionnel</p>"
         test.cleanUp()
     return (note, comment)
from tests import Tests
from urllib.parse import urlparse


service = Tests("https://yourwebsite.com")

service.runTestOne()
service.runTestTwo()
service.runTestThree()
service.runTestFour()
service.runTestFive()
service.runTestSix()
service.runTestSeven()
Exemple #14
0
def tests(*args, **kwargs):
    cam = kwargs['ctx']['cam']
    test = Tests(cam)
    return jsonify(test.avaliable_tests())
Exemple #15
0
 def __init__(self):
     self.t = Tests()
Exemple #16
0
 def get_available_tests(self):
     test = Tests(self)
     return test.avaliable_tests()['response']
from tests import Tests

lists = []

for i in range(2):
    a = input('a: ')
    b = input('b: ')

    lists.append(Tests(a, b))

for test in lists:
    print('{} and {}'.format(test.a, test.b))
Exemple #18
0
def run_test(*args, **kwargs):
    cam = kwargs['ctx']['cam']
    test_type = kwargs['test_type']
    method_name = kwargs['method_name']
    test = Tests(cam)
    return jsonify(test.service_test(test_type, method_name))
Exemple #19
0
from flask.ext.script import Manager
from flask import current_app
from tests import Tests
from routes import Routes

sub_manager = Manager(current_app)
sub_manager.add_command('test', Tests())
sub_manager.add_command('routes', Routes())
Exemple #20
0
def start_test_four(t):
    r = t.exec_fourth()
    parole, res = r[0], r[1]

    print parole, res

    plt.figure()
    plt.plot([2, 3, 4], res)
    plt.title('numero parole trovate al variare dei grammi')
    plt.xlabel('grammi')
    plt.ylabel('numero parole trovate')
    plt.legend(parole)
    plt.grid()


def start_test_five(t):
    t.exec_fifth()


if __name__ == '__main__':

    t = Tests()
    start_test_one(t)
    start_test_two(t)
    start_test_three(t)
    start_test_four(t)
    start_test_five(t)

    plt.show()
Exemple #21
0
def run_tests():
    tests = Tests()
    tests.test_correlation_id()
Exemple #22
0
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""

#-------------------------------------------------------------------------
# MAIN
#-------------------------------------------------------------------------
if __name__ == '__main__':
    import sys
    sys.path.append('src/')
    from tests import Tests

    #
    # VARIABLES
    #
    tests = Tests()

    #
    # CODE
    #
    # for each appropriate chunk of the original code we need one test to ensure it is working
    args = [
        './br-make_tests.py', "environments/", "test3", "log/", "measurements/"
    ]
    #args = sys.argv

    #tests.bank__get_parameters_from_file(args)             #tricky one, havent tried yet
    #tests.bank__apply_sifi_surcharge(args)                 #tricky one, havent tried yet
    #tests.bank__update_maturity(args)
    #tests.bank__update_risk_aversion(args)                 #tricky one, doesnt work yet, havent changed anything
    #tests.bank__get_interest(args)
Exemple #23
0
from bar import Bar
from interfazBaseDeDatos import InterfazBaseDeDatos
from interfazDeUsuario import InterfazDeUsuario
from interfazMaps import InterfazMaps
from listaBares import ListaDeBares
from tests import Tests

db2 = "file.txt"
test1 = Tests(db2)
"""test1.testAgregar()
test1.testDarDeAlta()
test1.testBuscarBaresCercanos()"""
test1.testOrdenarBaresPor()