Commit 421a4a62 authored by Eric Fossum's avatar Eric Fossum

Added tests, but they fail.

parent 6da919d0
......@@ -42,10 +42,11 @@ TESTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tests
# Test Files
TESTFILES= \
${TESTDIR}/TestFiles/f1
${TESTDIR}/TestFiles/f2
# Test Object Files
TESTOBJECTFILES=
TESTOBJECTFILES= \
${TESTDIR}/tests/linuxi2ctest.o
# C Compiler Flags
CFLAGS=
......@@ -83,9 +84,15 @@ ${OBJECTDIR}/src/linux-i2c.o: src/linux-i2c.cpp
.build-tests-conf: .build-tests-subprojects .build-conf ${TESTFILES}
.build-tests-subprojects:
${TESTDIR}/TestFiles/f1: ${OBJECTFILES:%.o=%_nomain.o}
${TESTDIR}/TestFiles/f2: ${TESTDIR}/tests/linuxi2ctest.o ${OBJECTFILES:%.o=%_nomain.o}
${MKDIR} -p ${TESTDIR}/TestFiles
${LINK.cc} -o ${TESTDIR}/TestFiles/f1 $^ ${LDLIBSOPTIONS}
${LINK.cc} -o ${TESTDIR}/TestFiles/f2 $^ ${LDLIBSOPTIONS}
${TESTDIR}/tests/linuxi2ctest.o: tests/linuxi2ctest.cpp
${MKDIR} -p ${TESTDIR}/tests
${RM} "$@.d"
$(COMPILE.cc) -g -Iinclude -I. -std=c++98 -MMD -MP -MF "$@.d" -o ${TESTDIR}/tests/linuxi2ctest.o tests/linuxi2ctest.cpp
${OBJECTDIR}/src/linux-i2c_nomain.o: ${OBJECTDIR}/src/linux-i2c.o src/linux-i2c.cpp
......@@ -105,7 +112,7 @@ ${OBJECTDIR}/src/linux-i2c_nomain.o: ${OBJECTDIR}/src/linux-i2c.o src/linux-i2c.
.test-conf:
@if [ "${TEST}" = "" ]; \
then \
${TESTDIR}/TestFiles/f1 || true; \
${TESTDIR}/TestFiles/f2 || true; \
else \
./${TEST} || true; \
fi
......
......@@ -42,10 +42,11 @@ TESTDIR=${CND_BUILDDIR}/${CND_CONF}/${CND_PLATFORM}/tests
# Test Files
TESTFILES= \
${TESTDIR}/TestFiles/f1
${TESTDIR}/TestFiles/f2
# Test Object Files
TESTOBJECTFILES=
TESTOBJECTFILES= \
${TESTDIR}/tests/linuxi2ctest.o
# C Compiler Flags
CFLAGS=
......@@ -83,9 +84,15 @@ ${OBJECTDIR}/src/linux-i2c.o: src/linux-i2c.cpp
.build-tests-conf: .build-tests-subprojects .build-conf ${TESTFILES}
.build-tests-subprojects:
${TESTDIR}/TestFiles/f1: ${OBJECTFILES:%.o=%_nomain.o}
${TESTDIR}/TestFiles/f2: ${TESTDIR}/tests/linuxi2ctest.o ${OBJECTFILES:%.o=%_nomain.o}
${MKDIR} -p ${TESTDIR}/TestFiles
${LINK.cc} -o ${TESTDIR}/TestFiles/f1 $^ ${LDLIBSOPTIONS}
${LINK.cc} -o ${TESTDIR}/TestFiles/f2 $^ ${LDLIBSOPTIONS}
${TESTDIR}/tests/linuxi2ctest.o: tests/linuxi2ctest.cpp
${MKDIR} -p ${TESTDIR}/tests
${RM} "$@.d"
$(COMPILE.cc) -O2 -I. -MMD -MP -MF "$@.d" -o ${TESTDIR}/tests/linuxi2ctest.o tests/linuxi2ctest.cpp
${OBJECTDIR}/src/linux-i2c_nomain.o: ${OBJECTDIR}/src/linux-i2c.o src/linux-i2c.cpp
......@@ -105,7 +112,7 @@ ${OBJECTDIR}/src/linux-i2c_nomain.o: ${OBJECTDIR}/src/linux-i2c.o src/linux-i2c.
.test-conf:
@if [ "${TEST}" = "" ]; \
then \
${TESTDIR}/TestFiles/f1 || true; \
${TESTDIR}/TestFiles/f2 || true; \
else \
./${TEST} || true; \
fi
......
......@@ -20,10 +20,11 @@
displayName="Test Files"
projectFiles="false"
kind="TEST_LOGICAL_FOLDER">
<logicalFolder name="f1"
displayName="C++ Simple Test"
<logicalFolder name="f2"
displayName="Linux I2C Test"
projectFiles="true"
kind="TEST">
<itemPath>tests/linuxi2ctest.cpp</itemPath>
</logicalFolder>
</logicalFolder>
<logicalFolder name="ExternalFiles"
......@@ -59,7 +60,7 @@
<commandLine>-v</commandLine>
</linkerTool>
</compileType>
<folder path="TestFiles/f1">
<folder path="TestFiles/f2">
<cTool>
<incDir>
<pElem>.</pElem>
......@@ -71,7 +72,7 @@
</incDir>
</ccTool>
<linkerTool>
<output>${TESTDIR}/TestFiles/f1</output>
<output>${TESTDIR}/TestFiles/f2</output>
</linkerTool>
</folder>
<item path="include/I2cBase.h" ex="false" tool="3" flavor2="0">
......@@ -80,6 +81,8 @@
</item>
<item path="src/linux-i2c.cpp" ex="false" tool="1" flavor2="0">
</item>
<item path="tests/linuxi2ctest.cpp" ex="false" tool="1" flavor2="0">
</item>
</conf>
<conf name="Release" type="2">
<toolsSet>
......@@ -101,7 +104,7 @@
<developmentMode>5</developmentMode>
</asmTool>
</compileType>
<folder path="TestFiles/f1">
<folder path="TestFiles/f2">
<cTool>
<incDir>
<pElem>.</pElem>
......@@ -113,7 +116,7 @@
</incDir>
</ccTool>
<linkerTool>
<output>${TESTDIR}/TestFiles/f1</output>
<output>${TESTDIR}/TestFiles/f2</output>
</linkerTool>
</folder>
<item path="include/I2cBase.h" ex="false" tool="3" flavor2="0">
......@@ -122,6 +125,8 @@
</item>
<item path="src/linux-i2c.cpp" ex="false" tool="1" flavor2="0">
</item>
<item path="tests/linuxi2ctest.cpp" ex="false" tool="1" flavor2="0">
</item>
</conf>
</confs>
</configurationDescriptor>
/*
* File: linuxi2ctest.cpp
* Author: ericfoss
*/
#include <stdlib.h>
#include <iostream>
#include "linux-i2c.h"
/*
* Simple C++ Test Suite
*/
const char GOOD_ADDR = 0x4c;
void bad_path_test() {
bool threw = false;
try {
LinuxI2c i2c("/fake/path", GOOD_ADDR);
} catch(...) {
threw = true;
}
if (!threw) {
std::cout << "%TEST_FAILED% time=0 testname=bad_path_test (linuxi2ctest) message=Bad constructor didn't throw" << std::endl;
}
}
void bad_address_test() {
bool threw = false;
try {
LinuxI2c i2c("/dev/i2c2", 0x00);
} catch(...) {
threw = true;
}
if (!threw) {
std::cout << "%TEST_FAILED% time=0 testname=bad_address_test (linuxi2ctest) message=Bad constructor didn't throw" << std::endl;
}
}
void good_construtor_test() {
bool threw = true;
try {
LinuxI2c i2c("/dev/i2c2", GOOD_ADDR);
threw = false;
} catch(...) {}
if (threw) {
std::cout << "%TEST_FAILED% time=0 testname=good_construtor_test (linuxi2ctest) message=Good constructor threw" << std::endl;
}
}
int main(int argc, char** argv) {
std::cout << "%SUITE_STARTING% linuxi2ctest" << std::endl;
std::cout << "%SUITE_STARTED%" << std::endl;
std::cout << "%TEST_STARTED% bad_path_test (linuxi2ctest)" << std::endl;
bad_path_test();
std::cout << "%TEST_FINISHED% time=0 bad_path_test (linuxi2ctest)" << std::endl;
std::cout << "%TEST_STARTED% bad_address_test (linuxi2ctest)" << std::endl;
bad_address_test();
std::cout << "%TEST_FINISHED% time=0 bad_address_test (linuxi2ctest)" << std::endl;
std::cout << "%TEST_STARTED% good_construtor_test (linuxi2ctest)" << std::endl;
good_construtor_test();
std::cout << "%TEST_FINISHED% time=0 good_construtor_test (linuxi2ctest)" << std::endl;
std::cout << "%SUITE_FINISHED% time=0" << std::endl;
return (EXIT_SUCCESS);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment