예제 #1
0
 def test_get_includes(self):
     define_constants('TestEnum1', ['a', 'b'], 'iostream')
     define_constants('TestEnum2', ['a', 'b'], 'stdio')
     self.assertEqual(
         get_includes_as_include_macros(),
         '#include <iostream>\n#include <stdbool.h>\n#include <stdio>\n')
     self.assertEqual(
         get_includes_in_define_macro(),
         '#define INCLUDES "iostream", \\\n"stdbool.h", \\\n"stdio"')
예제 #2
0
 def test_get_enums_with_all_vals(self):
     define_constants(name='TestEnum',
                      values=['a'],
                      include_header_file='stdio',
                      multi_valued=True,
                      skip_conversions=True,
                      wrap_macros_with_if_defined=True,
                      data_type='int64_t')
     self.assertEqual(
         get_constants(),
         '#define ENUMS_INIT \\\n{"TestEnum", {true, true, true, '
         '"int64_t", {{"a", a}}}}\n')
예제 #3
0
 def test_include_header_file_exceptions(self):
     with self.assertRaises(ValueError):
         define_constants('TestEnum1', ['a', 'b'], '<my_header_file>')
     with self.assertRaises(ValueError):
         define_constants('TestEnum2', ['a', 'b'], '"my_header_file"')
     with self.assertRaises(ValueError):
         define_constants('TestEnum', ['a', 'b'],
                          '#include "myheaderfile.h"')
예제 #4
0
Describes the types that need to be generated with the default values on the
target implementation. For each type, only include the values/members that are
present in newlib as well as the target host library.
"""

from asylo.platform.system_call.type_conversions.types_parse_functions import define_constants
from asylo.platform.system_call.type_conversions.types_parse_functions import define_struct
from asylo.platform.system_call.type_conversions.types_parse_functions import set_klinux_prefix
from asylo.platform.system_call.type_conversions.types_parse_functions import write_output

set_klinux_prefix("kLinux")

define_constants(name="FileStatusFlag",
                 values=[
                     "O_RDONLY", "O_WRONLY", "O_RDWR", "O_CREAT", "O_APPEND",
                     "O_EXCL", "O_TRUNC", "O_NONBLOCK", "O_DIRECT", "O_CLOEXEC"
                 ],
                 include_header_file="fcntl.h",
                 multi_valued=True)

define_constants(name="FileModeFlag",
                 values=[
                     "S_IFMT", "S_IFDIR", "S_IFCHR", "S_IFBLK", "S_IFREG",
                     "S_IFIFO", "S_IFLNK", "S_IFSOCK", "S_ISUID", "S_ISGID",
                     "S_ISVTX", "S_IRUSR", "S_IWUSR", "S_IXUSR", "S_IRGRP",
                     "S_IWGRP", "S_IXGRP", "S_IRWXG", "S_IROTH", "S_IWOTH",
                     "S_IXOTH", "S_IRWXO"
                 ],
                 include_header_file="fcntl.h",
                 multi_valued=True)
예제 #5
0
 def test_get_enums_with_only_default_vals(self):
     define_constants('TestEnum', ['a', 'b'], 'iostream')
     self.assertEqual(
         get_constants(), '#define ENUMS_INIT \\\n'
         '{"TestEnum", {0, 0, false, false, false, false, "int", '
         '{{"a", a}, {"b", b}}}}\n')