Ignoring the file issue for the moment, how does the program get a single 'm' and 'a' value?
On the command line, like ./testprog 10 20
Or as a prompt from within the program Enter m and a values
10 20
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
> Its kinda hard to describe clearly here, but hope you get a picture.
The source code for the program you're trying to test, or at least the bit of it where it "gets the values m and a" would make it much clearer.
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
Take your pick
#include <stdio.h>
#include <stdlib.h>
int main ( int argc, char *argv[] ) {
int m, a;
if ( argc > 2 ) {
m = strtol(argv[1],NULL,10);
a = strtol(argv[2],NULL,10);
} else {
char buff[BUFSIZ];
printf( "Enter m and a values > " );
fflush( stdout );
if ( fgets( buff, sizeof buff, stdin ) != NULL ) {
sscanf( buff, "%d %d", &m, &a );
}
}
printf( "m=%d, a=%d\n", m, a );
return 0;
}
# parameters on command line
$ ./a.exe 22 33
m=22, a=33
# parameters entered at a prompt
$ ./a.exe
Enter m and a values > 33 44
m=33, a=44
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
Which brings me back to the my original question, how does your pre-compiled program read the input?
From the command line?
From a prompt?
How it runs affects how you drive it
say
echo 22 33 | testprogram
testprogram 22 33
> write a test script
Using what language
C
C++
C!*?#
DOS Batch file
Linux bash script
Perl
....
etc
This stuff is easy in any number of ways, but I'm not about to describe all of them for the lack of you being specific about what it is you have.
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
In other words:
You have 3 files
1) Data File -- what reads the data file?
2) Program -- calculates data from the file. How does the data get into the program?
3) Script file -- somehow runs the program and associates the data with the program. This depends on how the other two files interface.
WaltP
Posting Sage w/ dash of thyme
10,492 posts since May 2006
Reputation Points: 3,348
Solved Threads: 943
Waltp has interpreted my point correctly.
A test script using C to run a pre-compiled program with the input data in a separate file.
We treat a program as a black box w/o having any ability to modify the source. This is a software that a vendor delivered to us. With the set of requirements, wWe will now have to creat a scenarios (input data) to test this piece of new release software.
As a newbie, I just want to understand that simple concept, then apply toward that large scale testing.
But not one question answered. We therefore can't help because we don't know what to do either. Sorry.
WaltP
Posting Sage w/ dash of thyme
10,492 posts since May 2006
Reputation Points: 3,348
Solved Threads: 943