Assignment: Chat 1. Start the server program 2. Start client programs 3. Input data from standard input for the clients 4. Redirect standard output to files 5. Compare output files to input files 17 points total """ import os, time, subprocess from within_file import WithinFile points = 0 withinFile = WithinFile() print('Executing 2 clients with a single message...') args = ['java', 'ChatServer', '6001'] server_errors = open('server-errors.txt', 'w') server = subprocess.Popen(args, stderr=server_errors) time.sleep(1) shell_command = 'py input-writer.py 0 2 client1-msg.txt | java ChatClient 6001 >client1-recvd.txt 2>client1-errors.txt &' os.system(shell_command) shell_command = 'py input-writer.py 1 2 client2-msg.txt | java ChatClient 6001 >client2-recvd.txt 2>client2-errors.txt' os.system(shell_command)
1. Start the program with server command line args 2. Start the program with client command line args 3. Input data from standard input for the server and the client 4. Redirect standard output to files 5. Compare output files to input files 6. Compare transferred files to original files 14 points total """ import os, time from file_compare import FileCompare from within_file import WithinFile points= 0 compare= FileCompare() withinFile= WithinFile() shell_command= 'cd server; rm one-liners.txt' os.system( shell_command ) shell_command= 'cd client; rm Ameca_splendens.jpg' os.system( shell_command ) print( 'Executing server and client with a single message...' ) shell_command= 'cd server; py ../input-writer.py 2 2 server-msg.txt 2>errors.txt | py -u ../messenger_with_files.py -l 6001 >server-recvd.txt &' os.system( shell_command ) time.sleep( 1 ) shell_command= 'cd client; py ../input-writer.py 0 2 client-msg.txt 2>errors.txt | py -u ../messenger_with_files.py -l 6002 -p 6001 >client-recvd.txt' os.system( shell_command )
Automated testing Assignment: Chat 1. Start the server program 2. Start client programs 3. Input data from standard input for the clients 4. Redirect standard output to files 5. Compare output files to input files 17 points total """ import os, time, subprocess from within_file import WithinFile points= 0 withinFile= WithinFile() print( 'Executing 2 clients with a single message...' ) args= ['py','-u','ChatServer.py','6001'] server_errors= open( 'server-errors.txt', 'w' ) server= subprocess.Popen( args, stderr= server_errors ) time.sleep( 1 ) shell_command= 'py input-writer.py 0 2 client1-msg.txt | py -u ChatClient.py 6001 >client1-recvd.txt 2>client1-errors.txt &' os.system( shell_command ) shell_command= 'py input-writer.py 1 2 client2-msg.txt | py -u ChatClient.py 6001 >client2-recvd.txt 2>client2-errors.txt' os.system( shell_command )
Automated testing Assignment: Args and Input Test 1 for Java code Tests included: Does the program start? If not, perhaps the name is wrong? Is output written immediately? Does the program end when stdin ends? Does the program write the correct output? ''' import os, sys, time, subprocess from within_file import WithinFile from file_compare import FileCompare withinFile = WithinFile() compare = FileCompare() shell_command = 'rm output.txt' os.system(shell_command) program_name = 'InputProgram' #check whether the file is named correctly try: file_stat = os.stat(program_name + '.class') except FileNotFoundError: print(program_name + '.class does not exist; the name of your program must match exactly') sys.exit() if file_stat.st_size == 0:
1. Start the server program 2. Start client programs 3. Input data from standard input for the clients 4. Redirect standard output to files 5. Compare transferred files to original files 24 points total """ import os, time, subprocess from file_compare import FileCompare from within_file import WithinFile points = 0 compare = FileCompare() withinFile = WithinFile() shell_command = 'cd client1; rm one-liners.txt' os.system(shell_command) shell_command = 'cd client2; rm Ameca_splendens.jpg' os.system(shell_command) shell_command = 'cd client3; rm Ameca_splendens.jpg' os.system(shell_command) print('Executing multiple messages between clients...') args = ['py', '-u', 'ChatServer.py', '6001'] server_errors = open('server-errors.txt', 'w') server = subprocess.Popen(args, stderr=server_errors) time.sleep(1)
""" Automated testing Assignment: Chat Test 1 for Python code Tests included: Does the server start? If not, perhaps the name is wrong? Does the client start? If not, perhaps the name is wrong? Are messages transferred immediately? Does the client end when stdin ends? Does the client write the correct output? """ import os, sys, time, subprocess from within_file import WithinFile withinFile= WithinFile() shell_command= 'rm client1-recvd.txt' os.system( shell_command ) shell_command= 'rm client2-recvd.txt' os.system( shell_command ) server_program_name = 'ChatServer.py' client_program_name = 'ChatClient.py' #check whether the program files are named correctly try: file_stat= os.stat( server_program_name ) except FileNotFoundError: print( server_program_name + ' does not exist; the name of your server program must match exactly' ) sys.exit()
''' Automated testing Assignment: Messenger Test 1 for Python code Tests included: Does the program start? If not, perhaps the name is wrong? Is message transferred immediately? Does the program end when stdin ends? Does the program write the correct output? ''' import os, sys, time, subprocess from within_file import WithinFile from file_compare import FileCompare withinFile= WithinFile() compare= FileCompare() shell_command= 'rm server-recvd.txt' os.system( shell_command ) shell_command= 'rm client-recvd.txt' os.system( shell_command ) program_name = 'messenger.py' #check whether the file is named correctly try: file_stat= os.stat( program_name ) except FileNotFoundError: print( program_name + ' does not exist; the name of your program must match exactly' ) sys.exit()
''' Automated testing Assignment: Messenger with file transfers Test 1 for Java code Tests included: Does the program start? If not, perhaps the name is wrong? Is a file transferred immediately? Does the program end when stdin ends? Does the program transfer the file correctly? ''' import os, sys, time, subprocess from within_file import WithinFile from file_compare import FileCompare withinFile = WithinFile() compare = FileCompare() cur_dir = os.getcwd() shell_command = 'rm client/Ameca_splendens.jpg' os.system(shell_command) shell_command = 'rm server/one-liners.txt' os.system(shell_command) program_name = 'MessengerWithFiles' transfer_points = 0 #check whether the file is named correctly try: file_stat = os.stat(program_name + '.class') except FileNotFoundError: