def testCorrectness(rows,istoken): color = colors.bcolors() if safetyTest(rows,istoken) == True: print (color.OKGREEN+'Safety Test Passed!!!') else: print (color.FAIL+'Safety Test Failed!!!') if livelinessTest(rows) == True: print (color.OKGREEN + 'Liveliness Test Passed!!!') else: print (color.WARNING + 'Liveliness Test Failed!!!') if fairnessTest(rows) == True: print (color.OKGREEN + 'Fairness Test Passed!!!') else: print (color.WARNING + 'Fairness Test Failed!!!') print (color.ENDC)
def fairnessTest(rows): """ This function tests if the processes are being served in a fair way. The one who is waiting for long time must be given priority over others(FIFO)""" queue = [] flag = True color = colors.bcolors() for row in rows: if row[1] != 'None': queue.append(row[1]) continue if row[2] != 'None' and queue[0] != row[2]: print (color.WARNING + "Process " + str(row[2]) + "jumped ahead of the queue. Fairness violated at " + str(row[0]) ) return False elif row[2] != 'None': queue.remove(row[2]) return True
"\q": "Disconnect from the server and quit akdb client.", "\?": "List all commands supported in akdb.", "\d <table_name>": "Prints out table details", "\p <table_name>": "Prints out table", "\\t <table_name>?": "Check whether the given table exists in database or not.", "create sequence <sequence_name> <sql_expression>": "Creating sequence in AK_sequence table", "create table <table_name> <sql_expression>": "Create table", "create index <index_name> <sql_expression>": "Create index", "create trigger <trigger_name> <sql_expression>": "Create trigger", "select <sql_expression>": "Select data from table", "update <sql_expression>": "Update table", "history": "List all previously typed commands.", } ##instantiate the colours class bcolors = colors.bcolors() ##define data ip = "localhost" port = 1998 buffer_size = 1024 class AK_Console(cmd.Cmd): cli = None ##Initialization of the console. Sets up the prompt and # a welcome note. def __init__(self): cmd.Cmd.__init__(self) self.prompt = "akdb>"
'\d <table_name>': 'Prints out table details', '\p <table_name>': 'Prints out table', '\\t <table_name>?': 'Check whether the given table exists in database or not.', 'create sequence <sequence_name> <sql_expression>': 'Creating sequence in AK_sequence table', 'create table <table_name> <sql_expression>': 'Create table', 'create index <index_name> <sql_expression>': 'Create index', 'create trigger <trigger_name> <sql_expression>': 'Create trigger', 'select <sql_expression>': 'Select data from table', 'update <sql_expression>': 'Update table', 'history': 'List all previously typed commands.' } ##instantiate the colours class bcolors = colors.bcolors() ##define data ip = "localhost" port = 1998 buffer_size = 1024 class AK_Console(cmd.Cmd): cli = None ##Initialization of the console. Sets up the prompt and #a welcome note. def __init__(self): cmd.Cmd.__init__(self) self.prompt = "akdb>"