Added: qpid/dispatch/trunk/src/schema_c.py URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/schema_c.py?rev=1608947&view=auto ============================================================================== --- qpid/dispatch/trunk/src/schema_c.py (added) +++ qpid/dispatch/trunk/src/schema_c.py Tue Jul 8 20:31:13 2014 @@ -0,0 +1,108 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License +# + +""" +Generate C code from the router schema. +""" + +import sys +from qpid_dispatch_internal.management import QdSchema + +copyright="""/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +""" + +import re +from qpid_dispatch_internal.management import QdSchema, EnumType + +class Generator(object): + + def __init__(self): + self.schema = QdSchema() + self.prefix = ['qd_schema'] + + self.generate_enums() + + def header(self, name, text): + with open(name+'.h', 'w') as f: + f.write("#ifndef __%s_h__\n#define __%s_h__\n"%(name, name) + copyright + text + "\n#endif\n") + + def source(self, name, text): + with open(name+'.c', 'w') as f: + f.write(copyright + text) + + def identifier(self, name): return re.sub(r'\W','_', name) + + def underscore(self, names): return '_'.join([self.identifier(name) for name in names]) + + def prefix_name(self, names): return self.underscore(self.prefix + names) + + def type_name(self, names): return self.prefix_name(names + ['t']) + + class EnumGenerator(object): + def __init__(self, generator, entity, attribute): + self.generator, self.entity, self.attribute = generator, entity, attribute + self.tags = attribute.atype.tags + self.type_name = generator.type_name([entity.name, attribute.name]) + self.array = self.generator.prefix_name([entity.name, attribute.name, 'names']) + self.count = self.name('ENUM_COUNT') + + def name(self, tag): + return self.generator.prefix_name([self.entity.name, self.attribute.name, tag]).upper() + + def decl(self): + tags = self.tags + ['ENUM_COUNT'] + return "typedef enum {\n" + \ + ",\n".join([" " + self.name(tag) for tag in tags]) + \ + "\n} %s;\n\n" % self.type_name + \ + "extern const char *%s[%s];\n\n" % (self.array, self.count) + + def defn(self): + return "const char *%s[%s] = {\n" % (self.array, self.count) + \ + ",\n".join(' "%s"'%(self.name(tag)) for tag in self.tags) + \ + "\n};\n\n" + + def generate_enums(self): + enums = [self.EnumGenerator(self, entity, attribute) + for entity in self.schema.entity_types.itervalues() + for attribute in entity.attributes.itervalues() + if isinstance(attribute.atype, EnumType)] + self.header('schema_enum', '\n'.join(e.decl() for e in enums)) + self.source('schema_enum', '#include "schema_enum.h"\n\n' + '\n'.join(e.defn() for e in enums)) + +if __name__ == '__main__': + Generator()
Modified: qpid/dispatch/trunk/src/static_assert.h URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/static_assert.h?rev=1608947&r1=1608946&r2=1608947&view=diff ============================================================================== --- qpid/dispatch/trunk/src/static_assert.h (original) +++ qpid/dispatch/trunk/src/static_assert.h Tue Jul 8 20:31:13 2014 @@ -21,10 +21,12 @@ */ /** @file - STATIC_ASSERT allows you to do compile time assertions at file scope - or in a funciton. + * STATIC_ASSERT allows you to do compile time assertions at file scope or in a function. + * @param expr: a boolean expression that is valid at compile time. + * @param msg: a "message" that must also be a valid identifier, i.e. message_with_underscores */ + #ifdef __GNUC__ #define STATIC_ASSERT_HELPER(expr, msg) \ (!!sizeof(struct { unsigned int STATIC_ASSERTION__##msg: (expr) ? 1 : -1; })) Modified: qpid/dispatch/trunk/tests/management/schema.py URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/management/schema.py?rev=1608947&r1=1608946&r2=1608947&view=diff ============================================================================== --- qpid/dispatch/trunk/tests/management/schema.py (original) +++ qpid/dispatch/trunk/tests/management/schema.py Tue Jul 8 20:31:13 2014 @@ -21,7 +21,7 @@ #pylint: disable=wildcard-import,missing-docstring,too-many-public-methods import unittest, json, sys -from qpid_dispatch_internal.management import Schema, Entity, EntityType, BooleanType, EnumType, AttributeType, schema_file, ValidationError +from qpid_dispatch_internal.management import Schema, Entity, EntityType, BooleanType, EnumType, AttributeType, schema_file, ValidationError, EnumValue import collections def replace_od(thing): @@ -78,11 +78,13 @@ class SchemaTest(unittest.TestCase): e = EnumType(['a', 'b', 'c']) self.assertEqual(e.validate('a'), 'a') self.assertEqual(e.validate(1), 'b') - self.assertEqual(e.validate('c', enum_as_int=True), 2) - self.assertEqual(e.validate(2, enum_as_int=True), 2) + self.assertEqual(e.validate('c'), 2) + self.assertEqual(e.validate(2), 2) self.assertRaises(ValidationError, e.validate, 'foo') self.assertRaises(ValidationError, e.validate, 3) + self.assertEqual('["x"]', json.dumps([EnumValue('x',3)])) + def test_attribute_def(self): a = AttributeType('foo', 'String', default='FOO') self.assertEqual('FOO', a.missing_value()) Modified: qpid/dispatch/trunk/tests/run.py.in URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/run.py.in?rev=1608947&r1=1608946&r2=1608947&view=diff ============================================================================== --- qpid/dispatch/trunk/tests/run.py.in (original) +++ qpid/dispatch/trunk/tests/run.py.in Tue Jul 8 20:31:13 2014 @@ -63,7 +63,8 @@ env_vars = { os.environ['PATH'].split(os.pathsep))), 'SOURCE_DIR': "${CMAKE_SOURCE_DIR}", 'BUILD_DIR': "${CMAKE_BINARY_DIR}", - 'QPID_DISPATCH_HOME': "${CMAKE_SOURCE_DIR}" + 'QPID_DISPATCH_HOME': "${CMAKE_SOURCE_DIR}", + 'QPID_DISPATCH_LIB': "${CMAKE_BINARY_DIR}/src/libqpid-dispatch.so.${SO_VERSION_MAJOR}" } os.environ.update(env_vars) @@ -117,22 +118,26 @@ def run_path(file_path, run_name=None): os.execvp(sys.executable, [sys.executable]+sys.argv) if __name__ == "__main__": - if len(sys.argv) == 1: - print usage - elif sys.argv[1] == '-m': - sys.argv = sys.argv[2:] - runpy.run_module(sys.argv[0], alter_sys=True, run_name="__main__") - elif sys.argv[1] == '-s': - sys.argv = sys.argv[2:] - run_path(sys.argv[0], run_name="__main__") - elif sys.argv[1] == '--sh': - for name, value in env_vars.iteritems(): print "%s=%s"%(name, value) - print "export %s"%' '.join(env_vars.keys()) - elif sys.argv[1] == '--vg': - args = with_valgrind(sys.argv[2:]) - os.execvp(args[0], args) - elif sys.argv[1].startswith('-'): - print usage - else: - args = sys.argv[1:] - os.execvp(args[0], args) + try: + if len(sys.argv) == 1: + print usage + elif sys.argv[1] == '-m': + sys.argv = sys.argv[2:] + runpy.run_module(sys.argv[0], alter_sys=True, run_name="__main__") + elif sys.argv[1] == '-s': + sys.argv = sys.argv[2:] + run_path(sys.argv[0], run_name="__main__") + elif sys.argv[1] == '--sh': + for name, value in env_vars.iteritems(): print "%s=%s"%(name, value) + print "export %s"%' '.join(env_vars.keys()) + elif sys.argv[1] == '--vg': + args = with_valgrind(sys.argv[2:]) + os.execvp(args[0], args) + elif sys.argv[1].startswith('-'): + print usage + else: + args = sys.argv[1:] + os.execvp(args[0], args) + except Exception, e: + raise Exception, "Error in %s: %s"%(" ".join(sys.argv), e), sys.exc_info()[2] + sys.exit(1) Modified: qpid/dispatch/trunk/tests/run_unit_tests.c URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/run_unit_tests.c?rev=1608947&r1=1608946&r2=1608947&view=diff ============================================================================== --- qpid/dispatch/trunk/tests/run_unit_tests.c (original) +++ qpid/dispatch/trunk/tests/run_unit_tests.c Tue Jul 8 20:31:13 2014 @@ -6,9 +6,9 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -35,10 +35,8 @@ int main(int argc, char** argv) exit(1); } - qd_dispatch_t *qd = qd_dispatch(0); + qd_dispatch_t *qd = qd_dispatch(0, 0); qd_dispatch_load_config(qd, argv[1]); - qd_dispatch_configure_container(qd); - qd_dispatch_prepare(qd); int result = 0; result += tool_tests(); @@ -50,4 +48,3 @@ int main(int argc, char** argv) result += timer_tests(); return result; } - Modified: qpid/dispatch/trunk/tests/system_test.py URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/system_test.py?rev=1608947&r1=1608946&r2=1608947&view=diff ============================================================================== --- qpid/dispatch/trunk/tests/system_test.py (original) +++ qpid/dispatch/trunk/tests/system_test.py Tue Jul 8 20:31:13 2014 @@ -275,7 +275,9 @@ class Qdrouterd(Process): """Run a Qpid Dispatch Router Daemon""" class Config(list, Config): - """List of ('section', {'name':'value', ...}). + """ + List of ('section', {'name':'value', ...}). + Fills in some default values automatically, see Qdrouterd.DEFAULTS """ @@ -310,6 +312,8 @@ class Qdrouterd(Process): @keyword wait: wait for router to be ready (call self.wait_ready()) """ self.config = copy(config) + if not [l for l in config if l[0] == 'log']: + config.append(('log', {'module':'DEFAULT', 'level':'info', 'output':name+'.log'})) if not pyinclude and os.environ['QPID_DISPATCH_HOME']: pyinclude = os.path.join(os.environ['QPID_DISPATCH_HOME'], 'python') super(Qdrouterd, self).__init__( Modified: qpid/dispatch/trunk/tests/threads4.conf URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/threads4.conf?rev=1608947&r1=1608946&r2=1608947&view=diff ============================================================================== --- qpid/dispatch/trunk/tests/threads4.conf (original) +++ qpid/dispatch/trunk/tests/threads4.conf Tue Jul 8 20:31:13 2014 @@ -24,3 +24,7 @@ container { worker-threads: 4 } +log { + module: DEFAULT + level: debug +} Modified: qpid/dispatch/trunk/tools/qdstat URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/tools/qdstat?rev=1608947&r1=1608946&r2=1608947&view=diff ============================================================================== --- qpid/dispatch/trunk/tools/qdstat (original) +++ qpid/dispatch/trunk/tools/qdstat Tue Jul 8 20:31:13 2014 @@ -26,11 +26,13 @@ import locale import socket import re from proton import Messenger, Message, Timeout -from qpid_dispatch_internal.management import Url, Node, Entity -home = os.environ.get("QPID_DISPATCH_HOME", os.path.normpath(os.path.dirname(__file__))) -sys.path.append(os.path.join(home, "python")) +home = os.environ.get("QPID_DISPATCH_HOME") +if not home: + home = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'lib', 'qpid-dispatch') +sys.path.insert(0, os.path.join(home, "python")) +from qpid_dispatch_internal.management import Url, Node, Entity from qpid_dispatch_internal.tools import Display, Header, Sorter, YN, Commas, TimeLong --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
