f3c5d9a59c
git-svn-id: file:///srv/dev-disk-by-uuid-17e88007-4d0c-45e0-8757-cacfcc458630/repositories/svn/Diplomarbeit@108 9fe90eed-be63-e94b-8204-d34ff4c2ff93
1 line
4.2 KiB
C
1 line
4.2 KiB
C
/* ---------------------------------------------------------------------------
|
|
* ethernet_test.c (c) 2008 Micro-key bv
|
|
* ---------------------------------------------------------------------------
|
|
* Micro-key bv
|
|
* Industrieweg 28, 9804 TG Noordhorn
|
|
* Postbus 92, 9800 AB Zuidhorn
|
|
* The Netherlands
|
|
* Tel: +31 594 503020
|
|
* Fax: +31 594 505825
|
|
* Email: support@microkey.nl
|
|
* Web: www.microkey.nl
|
|
* ---------------------------------------------------------------------------
|
|
* Description:
|
|
* ---------------------------------------------------------------------------
|
|
* Version(s): 0.1, Dez 11, 2008, MMi
|
|
* Creation.
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
|
|
/* ---------------------------------------------------------------------------
|
|
* System include files
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
#include <stdio.h>
|
|
#include <fcntl.h>
|
|
#include <string.h>
|
|
/* ---------------------------------------------------------------------------
|
|
* Application include files
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
#include "ethernet_test.h"
|
|
/* ---------------------------------------------------------------------------
|
|
* Local constant and macro definitions
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
|
|
/* ---------------------------------------------------------------------------
|
|
* Global variable definitions
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
|
|
/* ---------------------------------------------------------------------------
|
|
* Local variable definitions
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
|
|
/* ---------------------------------------------------------------------------
|
|
* Local function definitions
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
|
|
void ethernet_test_execute (void)
|
|
{
|
|
BOOLEAN test_result;
|
|
|
|
test_result = eth0_test();
|
|
|
|
|
|
/* Transfer test result to master */
|
|
bpSendRpcResult(bushandler, REMOTEDEVICENUMBER, 2, 1, 1, &test_result);
|
|
/* Release test Semaphore on Master by calling general release function */
|
|
bpSendRpcResult(handleBus1, 1, 1, 1, 0, NULL);
|
|
}
|
|
|
|
BOOLEAN eth0_test (void)
|
|
{
|
|
int fd;
|
|
int rd;
|
|
char readback[512];
|
|
BOOLEAN test_result;
|
|
|
|
printf ("THIS IS THE ETHERNET TEST SEQUENCE");
|
|
|
|
/* Call local test script */
|
|
system ("/./test/eth0_test");
|
|
|
|
/* Software continues here after script is ended
|
|
* Try to open test result file
|
|
*/
|
|
if ((fd = open ("result/eth0.res", O_RDONLY, 0)) == -1)
|
|
{
|
|
/* Opening was not successful - Set test result to false */
|
|
printf ("Cannot open File");
|
|
test_result = FALSE;
|
|
}
|
|
else
|
|
{
|
|
/* Opening was sucessful - Try to read content of result file */
|
|
if ((rd = read (fd, readback, 512)) == -1)
|
|
{
|
|
/* Reading was not sucessful - Set test result to false */
|
|
printf ("Cannot read from file");
|
|
test_result = FALSE;
|
|
}
|
|
else
|
|
{
|
|
/* Reading was sucessful - Try to find the result keyword */
|
|
if ((strstr (readback, "PASSED")) != NULL)
|
|
{
|
|
/* Keyword "PASSED" found - Set test resulr to true */
|
|
printf ("\n\rTest is PASSED\n\r");
|
|
test_result = TRUE;
|
|
}
|
|
|
|
else if ((strstr (readback, "FAILED")) != NULL)
|
|
{
|
|
/* Keyword "FAILED" found - Set test result to false */
|
|
printf ("\n\rTest is FAILED\n\r");
|
|
test_result = FALSE;
|
|
}
|
|
|
|
else
|
|
{
|
|
/* No Keyword found - Set test result to false */
|
|
printf ("No result found in file");
|
|
test_result = FALSE;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return (test_result); /* Transmit test result */
|
|
}
|
|
|