Compare commits
2 commits
master
...
mp/test-bi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f148fc7c34 | ||
|
|
6e4fcafbc3 |
12 changed files with 234 additions and 11 deletions
|
|
@ -790,7 +790,6 @@ int STEPattribute::is_null() const {
|
||||||
return ( *( ptr.S ) == S_STRING_NULL );
|
return ( *( ptr.S ) == S_STRING_NULL );
|
||||||
|
|
||||||
case BINARY_TYPE:
|
case BINARY_TYPE:
|
||||||
ptr.b->clear();
|
|
||||||
return ptr.b->empty();
|
return ptr.b->empty();
|
||||||
|
|
||||||
case AGGREGATE_TYPE:
|
case AGGREGATE_TYPE:
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,7 @@
|
||||||
#include <SingleLinkList.h>
|
#include <SingleLinkList.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
SingleLinkNode *
|
SingleLinkNode * SingleLinkNode::NextNode() const {
|
||||||
SingleLinkNode::NextNode() const {
|
|
||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ int PrintAttrsHTML( const EntityDescriptor * ent, ofstream & outhtml ) {
|
||||||
while( attrDesc != 0 ) {
|
while( attrDesc != 0 ) {
|
||||||
attrCount++;
|
attrCount++;
|
||||||
outhtml << "<LI>" << attrDesc->Name() << " : ";
|
outhtml << "<LI>" << attrDesc->Name() << " : ";
|
||||||
if( ( SDAI_Logical )( attrDesc->Optional() ) == SCLLOG( LTrue ) ) {
|
if( attrDesc->Optional().operator==( LTrue ) ) {
|
||||||
outhtml << "optional ";
|
outhtml << "optional ";
|
||||||
}
|
}
|
||||||
PrintAttrTypeWithAnchor( attrDesc->ReferentType(), outhtml );
|
PrintAttrTypeWithAnchor( attrDesc->ReferentType(), outhtml );
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ void PopulateEntity( STEPentity * ent ) {
|
||||||
const AttrDescriptor * attrDesc = attr->aDesc;
|
const AttrDescriptor * attrDesc = attr->aDesc;
|
||||||
cout << " attribute " << attrDesc->Name();
|
cout << " attribute " << attrDesc->Name();
|
||||||
cout << " [" << attrDesc->TypeName() << "] = ";
|
cout << " [" << attrDesc->TypeName() << "] = ";
|
||||||
int needOutput = 1; // true if we need to output the value
|
bool needOutput = true; // true if we need to output the value
|
||||||
// that is, if it's anything but 'none'
|
// that is, if it's anything but 'none'
|
||||||
|
|
||||||
// Here's how we do this... set up a string stream to put the value
|
// Here's how we do this... set up a string stream to put the value
|
||||||
|
|
@ -66,18 +66,23 @@ void PopulateEntity( STEPentity * ent ) {
|
||||||
valstr << se->element_at( rand() % se->no_elements() );
|
valstr << se->element_at( rand() % se->no_elements() );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case BINARY_TYPE: //FIXME we really need to query the number of bits (does scl/fedex_plus even support this?!)
|
||||||
|
cout << "(binary) ";
|
||||||
|
valstr << "\"1";
|
||||||
|
valstr.setf(ios::hex,ios::basefield);
|
||||||
|
valstr << rand() % 100 << '\"';
|
||||||
|
SDAI_Binary b;
|
||||||
|
break;
|
||||||
default: // for other stuff like aggregates and selects, just leave
|
default: // for other stuff like aggregates and selects, just leave
|
||||||
cout << "none (" << attrDesc->NonRefType(); // 'em blank...
|
cout << "none (" << attrDesc->NonRefType(); // 'em blank...
|
||||||
cout << ")" << endl;
|
cout << ")" << endl;
|
||||||
needOutput = 0;
|
needOutput = false;
|
||||||
}
|
}
|
||||||
valstr << ends; // flush and null-terminate the stream
|
valstr << ends; // flush and null-terminate the stream
|
||||||
/*** char *val = valstr.str(); ***/ // fix stream into char* string
|
|
||||||
char * val = &( valstr.str()[0] );
|
|
||||||
if( needOutput ) {
|
if( needOutput ) {
|
||||||
cout << val << endl;
|
cout << valstr.str() << endl;
|
||||||
}
|
}
|
||||||
attr->StrToVal( val ); // and assign
|
attr->StrToVal( valstr.str().c_str() ); // and assign
|
||||||
|
|
||||||
attr = ent->NextAttribute();
|
attr = ent->NextAttribute();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,11 @@ FILE(GLOB UNITARY_SCHEMAS "${CMAKE_CURRENT_SOURCE_DIR}/unitary_schemas/*.exp")
|
||||||
FOREACH(UNITARY_SCHEMA ${UNITARY_SCHEMAS})
|
FOREACH(UNITARY_SCHEMA ${UNITARY_SCHEMAS})
|
||||||
GET_FILENAME_COMPONENT(SCHEMA_NAME ${UNITARY_SCHEMA} NAME_WE)
|
GET_FILENAME_COMPONENT(SCHEMA_NAME ${UNITARY_SCHEMA} NAME_WE)
|
||||||
# setting test_name
|
# setting test_name
|
||||||
SET(TEST_NAME test${SCHEMA_NAME})
|
SET(TEST_NAME test_unit_${SCHEMA_NAME})
|
||||||
# add test
|
# add test
|
||||||
ADD_TEST(${TEST_NAME} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/check-express ${UNITARY_SCHEMA})
|
ADD_TEST(${TEST_NAME} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/check-express ${UNITARY_SCHEMA})
|
||||||
set_tests_properties( ${TEST_NAME} PROPERTIES LABELS unitary_schemas )
|
set_tests_properties( ${TEST_NAME} PROPERTIES LABELS unitary_schemas )
|
||||||
ENDFOREACH(UNITARY_SCHEMA ${UNITARY_SCHEMAS})
|
ENDFOREACH(UNITARY_SCHEMA ${UNITARY_SCHEMAS})
|
||||||
|
|
||||||
add_subdirectory(p21)
|
add_subdirectory(p21)
|
||||||
|
add_subdirectory(cpp)
|
||||||
|
|
|
||||||
6
test/cpp/CMakeLists.txt
Normal file
6
test/cpp/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||||
|
|
||||||
|
#c++ tests
|
||||||
|
|
||||||
|
add_subdirectory(schema_dependent)
|
||||||
|
# add_subdirectory(stepcore)
|
||||||
20
test/cpp/schema_dependent/CMakeLists.txt
Normal file
20
test/cpp/schema_dependent/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||||
|
#c++ tests that depend on a particular schema
|
||||||
|
|
||||||
|
# ${name} is used for the C++ file name (${name}.cc), and as the suffix for the target and test names
|
||||||
|
# ${sdai_lib} is the name of the schema lib that is used
|
||||||
|
# ${args} are additional args for the test command
|
||||||
|
FUNCTION( add_schema_dependent_test name sdai_lib args )
|
||||||
|
add_executable( tst_${name} "${name}.cc" )
|
||||||
|
set_target_properties( tst_${name} PROPERTIES COMPILE_FLAGS "-I${SCL_SOURCE_DIR}/src/cldai -I${SCL_SOURCE_DIR}/src/cleditor -I${SCL_SOURCE_DIR}/src/clutils -I${CMAKE_BINARY_DIR}/${sdai_lib} -I${SCL_SOURCE_DIR}/src/clstepcore" )
|
||||||
|
set_target_properties( tst_${name} PROPERTIES EXCLUDE_FROM_ALL ON )
|
||||||
|
target_link_libraries( tst_${name} sdai_${sdai_lib} )
|
||||||
|
add_test( NAME test_${name}
|
||||||
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||||
|
COMMAND tst_${name} ${args} )
|
||||||
|
set_tests_properties( test_${name} PROPERTIES DEPENDS build_cpp_sdai_${sdai_lib} LABELS cpp )
|
||||||
|
ENDFUNCTION( add_schema_dependent_test name sdai_lib args )
|
||||||
|
|
||||||
|
add_schema_dependent_test( "binary_index_derived" "binary_index" "${SCL_SOURCE_DIR}/test/p21/test_binary_index.p21" )
|
||||||
|
add_schema_dependent_test( "stepAttrListSegfault" "binary_index" "${SCL_SOURCE_DIR}/test/p21/test_binary_index.p21" )
|
||||||
|
|
||||||
70
test/cpp/schema_dependent/binary_index_derived.cc
Normal file
70
test/cpp/schema_dependent/binary_index_derived.cc
Normal file
|
|
@ -0,0 +1,70 @@
|
||||||
|
|
||||||
|
extern void SchemaInit( class Registry & );
|
||||||
|
#include "scl_version_string.h"
|
||||||
|
#include <STEPfile.h>
|
||||||
|
#include <sdai.h>
|
||||||
|
#include <STEPattribute.h>
|
||||||
|
#include <ExpDict.h>
|
||||||
|
#include <Registry.h>
|
||||||
|
#include <errordesc.h>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <string>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "SdaiTEST_BINARY_INDEX.h"
|
||||||
|
|
||||||
|
//FIXME incomplete
|
||||||
|
int main( int argc, char * argv[] ) {
|
||||||
|
|
||||||
|
if ( argc != 2 ) {
|
||||||
|
cerr << "Wrong number of args. Use: " << argv[0] << " file.stp" << endl;
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Registry registry( SchemaInit );
|
||||||
|
InstMgr instance_list;
|
||||||
|
STEPfile sfile( registry, instance_list, "", false );
|
||||||
|
|
||||||
|
sfile.ReadExchangeFile( argv[1] );
|
||||||
|
sfile.Error().PrintContents(cout);
|
||||||
|
|
||||||
|
Severity readSev = sfile.Error().severity();
|
||||||
|
|
||||||
|
// Keeps track of the last processed ent id
|
||||||
|
int search_index = 0;
|
||||||
|
|
||||||
|
const EntityDescriptor* ed = registry.FindEntity("Buynary");
|
||||||
|
AttrDescItr aditr( ed->ExplicitAttr() );
|
||||||
|
const AttrDescriptor * attrDesc = aditr.NextAttrDesc();
|
||||||
|
while( attrDesc != 0 ) {
|
||||||
|
if( attrDesc->Derived() == LTrue ) {
|
||||||
|
cout << "attr: " << attrDesc->Name() << " initializer: " << ((Derived_attribute*) attrDesc)->initializer_() << endl;
|
||||||
|
//how to find the value of an attribute for an entity?
|
||||||
|
}
|
||||||
|
attrDesc = aditr.NextAttrDesc();
|
||||||
|
}
|
||||||
|
|
||||||
|
SdaiBuynary* ent;
|
||||||
|
while ( ENTITY_NULL != (ent = (SdaiBuynary*) instance_list.GetApplication_instance("Buynary",search_index) ) ) {
|
||||||
|
// Loop over the Buynarys in the file
|
||||||
|
cout << "Ent #" << ent->StepFileId() << endl;
|
||||||
|
SDAI_Binary b = ent->bin_();
|
||||||
|
int cnt = ent->AttributeCount();
|
||||||
|
cout << "bin " << b.asStr() << endl;
|
||||||
|
cout << "count " << cnt << endl;
|
||||||
|
STEPattributeList &sal = ent->attributes;
|
||||||
|
STEPattribute sa;
|
||||||
|
// AttrDescItr adi( ent->attributes );
|
||||||
|
// while 0 != (
|
||||||
|
for( int i = 0; i < cnt; i++ ) {
|
||||||
|
sa = sal[i];
|
||||||
|
if( ( sa.aDesc->Derived() == LTrue ) && ( sa.aDesc->BaseType() == sdaiBINARY ) ) {
|
||||||
|
cout << "derived: " << sa.ptr.b->asStr() << endl;
|
||||||
|
} else {
|
||||||
|
cout << "not derived: " << sa.ptr.b->asStr() << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MgrNode* mnode = instance_list.FindFileId( ent->StepFileId() );
|
||||||
|
search_index = instance_list.GetIndex( mnode ) + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
100
test/cpp/schema_dependent/stepAttrListSegfault.cc
Normal file
100
test/cpp/schema_dependent/stepAttrListSegfault.cc
Normal file
|
|
@ -0,0 +1,100 @@
|
||||||
|
|
||||||
|
extern void SchemaInit( class Registry & );
|
||||||
|
#include "scl_version_string.h"
|
||||||
|
#include <STEPfile.h>
|
||||||
|
#include <sdai.h>
|
||||||
|
#include <STEPattribute.h>
|
||||||
|
#include <ExpDict.h>
|
||||||
|
#include <Registry.h>
|
||||||
|
#include <errordesc.h>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <string>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "SdaiTEST_BINARY_INDEX.h"
|
||||||
|
|
||||||
|
/* TODO: simplify this as much as possible
|
||||||
|
* This segfault will probably occur with the STEPattributeList base class, SingleLinkList, as well - and without a schema lib.
|
||||||
|
*/
|
||||||
|
int main( int argc, char * argv[] ) {
|
||||||
|
|
||||||
|
if ( argc != 2 ) {
|
||||||
|
cerr << "Wrong number of args. Use: " << argv[0] << " file.stp" << endl;
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Registry registry( SchemaInit );
|
||||||
|
InstMgr instance_list;
|
||||||
|
STEPfile sfile( registry, instance_list, "", false );
|
||||||
|
|
||||||
|
sfile.ReadExchangeFile( argv[1] );
|
||||||
|
sfile.Error().PrintContents(cout);
|
||||||
|
|
||||||
|
Severity readSev = sfile.Error().severity();
|
||||||
|
|
||||||
|
// Keeps track of the last processed ent id
|
||||||
|
int search_index = 0;
|
||||||
|
|
||||||
|
const EntityDescriptor* ed = registry.FindEntity("Buynary");
|
||||||
|
AttrDescItr aditr( ed->ExplicitAttr() );
|
||||||
|
const AttrDescriptor * attrDesc = aditr.NextAttrDesc();
|
||||||
|
while( attrDesc != 0 ) {
|
||||||
|
if( attrDesc->Derived() == LTrue ) {
|
||||||
|
cout << "attr: " << attrDesc->Name() << " initializer: " << ((Derived_attribute*) attrDesc)->initializer_() << endl;
|
||||||
|
//how to find the value of an attribute for an entity?
|
||||||
|
}
|
||||||
|
attrDesc = aditr.NextAttrDesc();
|
||||||
|
}
|
||||||
|
|
||||||
|
SdaiBuynary* ent;
|
||||||
|
while ( ENTITY_NULL != (ent = (SdaiBuynary*) instance_list.GetApplication_instance("Buynary",search_index) ) ) {
|
||||||
|
// Loop over the Buynarys in the file
|
||||||
|
cout << "Ent #" << ent->StepFileId() << endl;
|
||||||
|
SDAI_Binary b = ent->bin_();
|
||||||
|
int cnt = ent->AttributeCount();
|
||||||
|
cout << "bin " << b.asStr() << endl;
|
||||||
|
cout << "count " << cnt << endl;
|
||||||
|
|
||||||
|
STEPattributeList sal = ent->attributes; //commenting this line out prevents the segfault
|
||||||
|
|
||||||
|
MgrNode* mnode = instance_list.FindFileId( ent->StepFileId() );
|
||||||
|
search_index = instance_list.GetIndex( mnode ) + 1;
|
||||||
|
}
|
||||||
|
/* attr: lasthalf initializer: bin[5:8]
|
||||||
|
* Ent #1
|
||||||
|
* bin 15A
|
||||||
|
* count 1
|
||||||
|
*
|
||||||
|
* Program received signal SIGSEGV, Segmentation fault.
|
||||||
|
* 0x000000000067f768 in ?? ()
|
||||||
|
* (gdb) bt
|
||||||
|
* #0 0x000000000067f768 in ?? ()
|
||||||
|
* #1 0x00007ffff778962d in SingleLinkList::Empty (this=0x6755b8)
|
||||||
|
* at /opt/step/scl/src/clstepcore/SingleLinkList.inline.cc:32
|
||||||
|
* #2 0x00007ffff77895b8 in SingleLinkList::~SingleLinkList (this=0x6755b8, __in_chrg=<optimized out>)
|
||||||
|
* at /opt/step/scl/src/clstepcore/SingleLinkList.inline.cc:26
|
||||||
|
* #3 0x00007ffff7788f64 in STEPattributeList::~STEPattributeList (this=0x6755b8, __in_chrg=<optimized out>)
|
||||||
|
* at /opt/step/scl/src/clstepcore/STEPattributeList.cc:27
|
||||||
|
* #4 0x00007ffff77778e0 in SDAI_Application_instance::~SDAI_Application_instance (this=0x6755a0,
|
||||||
|
* __in_chrg=<optimized out>) at /opt/step/scl/src/clstepcore/sdaiApplication_instance.cc:42
|
||||||
|
* #5 0x00007ffff7bdb163 in SdaiBuynary::~SdaiBuynary (this=0x6755a0, __in_chrg=<optimized out>)
|
||||||
|
* at /opt/step/scl/build/binary_index/SdaiTEST_BINARY_INDEX.cc:46
|
||||||
|
* #6 0x00007ffff7bdb1b6 in SdaiBuynary::~SdaiBuynary (this=0x6755a0, __in_chrg=<optimized out>)
|
||||||
|
* at /opt/step/scl/build/binary_index/SdaiTEST_BINARY_INDEX.cc:46
|
||||||
|
* #7 0x00007ffff79c8656 in MgrNode::~MgrNode (this=0x67f790, __in_chrg=<optimized out>)
|
||||||
|
* at /opt/step/scl/src/cleditor/mgrnode.cc:69
|
||||||
|
* #8 0x00007ffff79c86ee in MgrNode::~MgrNode (this=0x67f790, __in_chrg=<optimized out>)
|
||||||
|
* at /opt/step/scl/src/cleditor/mgrnode.cc:75
|
||||||
|
* #9 0x00007ffff79c8efd in MgrNodeArray::DeleteEntries (this=0x637940)
|
||||||
|
* at /opt/step/scl/src/cleditor/mgrnodearray.cc:84
|
||||||
|
* #10 0x00007ffff79c8d7f in MgrNodeArray::~MgrNodeArray (this=0x637940, __in_chrg=<optimized out>)
|
||||||
|
* at /opt/step/scl/src/cleditor/mgrnodearray.cc:60
|
||||||
|
* #11 0x00007ffff79c8dde in MgrNodeArray::~MgrNodeArray (this=0x637940, __in_chrg=<optimized out>)
|
||||||
|
* at /opt/step/scl/src/cleditor/mgrnodearray.cc:61
|
||||||
|
* #12 0x00007ffff79c7554 in InstMgr::~InstMgr (this=0x7fffffffe030, __in_chrg=<optimized out>)
|
||||||
|
* at /opt/step/scl/src/cleditor/instmgr.cc:58
|
||||||
|
* #13 0x0000000000402133 in main (argc=2, argv=0x7fffffffe1f8)
|
||||||
|
* at /opt/step/scl/test/cpp/schema_dependent/binary_index_derived.cc:25
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -52,3 +52,7 @@ set_tests_properties( test_good_schema_name test_good_schema_name_asn test_misma
|
||||||
PROPERTIES DEPENDS build_cpp_sdai_AP214E3_2010 LABELS exchange_file )
|
PROPERTIES DEPENDS build_cpp_sdai_AP214E3_2010 LABELS exchange_file )
|
||||||
|
|
||||||
set_tests_properties( test_mismatch_schema_name test_missing_and_required_strict PROPERTIES WILL_FAIL TRUE )
|
set_tests_properties( test_mismatch_schema_name test_missing_and_required_strict PROPERTIES WILL_FAIL TRUE )
|
||||||
|
|
||||||
|
#currently, this test is forced to fail - the file is written with a '$', but p21read reports no errors or warnings. The WILL_FAIL property can be removed when p21read reports an error or when it stores the correct data
|
||||||
|
add_test( test_binary_index "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/p21read_sdai_binary_index" ${CMAKE_CURRENT_SOURCE_DIR}/test_binary_index.p21 )
|
||||||
|
set_tests_properties( test_binary_index PROPERTIES DEPENDS build_cpp_sdai_binary_index WILL_FAIL TRUE LABELS exchange_file )
|
||||||
10
test/p21/test_binary_index.p21
Normal file
10
test/p21/test_binary_index.p21
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
ISO-10303-21;
|
||||||
|
HEADER;
|
||||||
|
FILE_DESCRIPTION(('SCL test file'),'2;1');
|
||||||
|
FILE_NAME('test_binary_index.stp','2012-01-19T',('mp'),(''),'0','1','2');
|
||||||
|
FILE_SCHEMA(('test_binary_index'));
|
||||||
|
ENDSEC;
|
||||||
|
DATA;
|
||||||
|
#1=BUYNARY("15A");
|
||||||
|
ENDSEC;
|
||||||
|
END-ISO-10303-21;
|
||||||
9
test/unitary_schemas/binary_index.exp
Normal file
9
test/unitary_schemas/binary_index.exp
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
SCHEMA test_binary_index;
|
||||||
|
|
||||||
|
ENTITY buynary;
|
||||||
|
bin : BINARY (8) FIXED;
|
||||||
|
DERIVE
|
||||||
|
lasthalf: BINARY (4) := bin[5:8];
|
||||||
|
END_ENTITY;
|
||||||
|
|
||||||
|
END_SCHEMA;
|
||||||
Loading…
Reference in a new issue