mercredi 20 novembre 2019

Testing a C program through subprocess.Popen in PYTHON, raises cygwin error

I am a student studying C right now and i have been trying to write test programs for my peers. I decided to write my test program in python due to knowing that all of the students have the same IDE and interpreter version.

I decided to work with subprocess.Popen. I unpack a tar file in that my C program is stored in using a tar command, then i compile the needed files using a gcc command. and then i run tests using input that is stored in text files, comparing the users output to expected outputs in corresponding text files.

when i run my C executable through the cmd, it works flawlessly and no errors appear. but when i try to run them through subprocess.Popen, i get a cygwin error in addition to the expected output, causing my testing program to report a test failure.

I use this function, supplying it with an array of strings as arguments for the command.

def run_cmd_command(arguments_list):
        """
        runs the given command through the command line and returns information
        about the command.
        :param arguments_list: a list representing the command to run
        :return: A tuple containing the returncode, the output of the command and
        all the errors.
        """
        process = subprocess.Popen(arguments_list, stdin=subprocess.PIPE,
                           stdout=subprocess.PIPE, stderr=subprocess.PIPE,
                           universal_newlines=True)
        output, errors = process.communicate()
        return process.returncode, output, errors

The test python program works properly when supplied with proper inputs.

On the other hand, when the inputs are not proper, the C program is supposed to print into stderr the string : "Invalid Input\n" but prints Invalid input 0 [main] TreeAnalyzer 1780 cygwin_exception::open_stackdumpfile: Dumping stack trace to TreeAnalyzer.exe.stackdump

I would like to supply you with more information but im not sure which information to supply due to not understand where the problem's may root from.

Aucun commentaire:

Enregistrer un commentaire