2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
28 #include <libkern/OSBase.h>
31 #include <mach/mach_types.h>
32 #include <mach/vm_types.h>
33 #include <mach/kmod.h>
35 kmod_start_func_t test1_start
;
36 kmod_stop_func_t test1_stop
;
39 #include <libkern/c++/OSContainers.h>
40 #include <iokit/IOLib.h>
42 const char *testBuffer
= ""
43 "{ string = \"this is a 'string' with spaces\";"
44 " string2 = 'this is also a \"string\" with spaces';"
48 " data = <0123 4567 89abcdef>;"
49 " array = (1:8, 2:16, 3:32, 4:64 );"
50 " set = [ one, two, three, four ];"
52 " emptyarray = ( )@2;"
59 " dict2 = { string = asdfasdf; };"
60 " dict3 = { string = asdfasdf; };"
64 test1_start(struct kmod_info
*ki
, void *data
)
66 IOLog("test buffer start:\n%s\n:test buffer end.\n", testBuffer
);
70 OSObject
*d
= OSUnserialize(testBuffer
, &errmsg
);
72 IOLog("%s\n", errmsg
->getCStringNoCopy());
73 return KMOD_RETURN_SUCCESS
;
77 OSSerialize
*s
= OSSerialize::withCapacity(5);
78 if (!d
->serialize(s
)) {
79 IOLog("serialization failed\n");
80 return KMOD_RETURN_SUCCESS
;
83 IOLog("serialized object's length = %d, capacity = %d\n", s
->getLength(), s
->getCapacity());
84 IOLog("object unformatted = %s\n", s
->text());
87 OSObject
*d2
= OSUnserializeXML(s
->text(), &errmsg
);
89 IOLog("%s\n", errmsg
->getCStringNoCopy());
90 return KMOD_RETURN_SUCCESS
;
93 IOLog("\nserialized objects compared %ssuccessfully objectwise\n\n",
94 d
->isEqualTo(d2
) ? "":"un");
104 return KMOD_RETURN_SUCCESS
;
108 test1_stop(struct kmod_info
*ki
, void *data
)
110 return KMOD_RETURN_SUCCESS
;