1 | //␊ |
2 | // ChameleonPrefPane␊ |
3 | //␊ |
4 | // test utility for the chameleon preference pane ␊ |
5 | //␊ |
6 | // Created by Rekursor on 11-11-12.␊ |
7 | //␊ |
8 | ␊ |
9 | #import <Foundation/Foundation.h>␊ |
10 | #import "PartitionInfoElement.h"␊ |
11 | #import "PartitionInfoManager.h"␊ |
12 | #import "SmbiosExtractor.h"␊ |
13 | #import "ShellProcess.h"␊ |
14 | #include "string_util.h"␊ |
15 | #include <string>␊ |
16 | #include <iostream>␊ |
17 | ␊ |
18 | void testDiskInfoWith(NSString * bsd)␊ |
19 | {␊ |
20 | ␉PartitionInfoElement* di = [[PartitionInfoElement alloc] initWithBSDName: bsd];␊ |
21 | ␉␊ |
22 | ␉if ([di isValid] && [di.vUUID length] >0)␊ |
23 | ␉{␊ |
24 | #if 1␊ |
25 | ␉␉NSLog(@"bsdName %@", [di bsdName] );␊ |
26 | ␉␉NSLog(@"deviceProtocol %@", [ di devProtocol] );␊ |
27 | ␉␉NSLog(@"volumeName %@", [di vName]);␊ |
28 | ␉␉NSLog(@"volumePath %@", [di vPath]);␊ |
29 | ␉␉NSLog(@"volumeKind %@", [di vKind]);␊ |
30 | ␉␉NSLog(@"deviceInternal %i", (int) [ di devInternal] );␊ |
31 | ␉␉NSLog(@"volumeUUID %@", [di vUUID]);␊ |
32 | ␉␉NSLog(@"mediaPath %@", [di mediaPath]);␊ |
33 | ␉␉NSLog(@"mediaRemovable %i", (int) [di mediaRemovable]);␊ |
34 | ␉␉␊ |
35 | ␉␉NSLog(@"\n");␊ |
36 | ␊ |
37 | #else␊ |
38 | ␉␉int i = 0;␊ |
39 | ␉␉for (NSString* o in di.descDict)␊ |
40 | ␉␉{␊ |
41 | ␉␉ id value = [di.descDict objectForKey: o];␊ |
42 | ␉␉ if (value == nil) value = @"<nil>";␊ |
43 | ␉␉ NSLog(@"Key: %@, Value: %@", o, value );␊ |
44 | ␉␉ i++;␊ |
45 | ␉␉}␊ |
46 | #endif␊ |
47 | ␉}␊ |
48 | ␊ |
49 | ␉[di release];␊ |
50 | }␊ |
51 | ␊ |
52 | int main (int argc, const char * argv[]) ␊ |
53 | {␊ |
54 | NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];␊ |
55 | ␉␊ |
56 | // smbios extractio testing␊ |
57 | ␉SmbiosExtractor* smbe = [[SmbiosExtractor alloc] init];␊ |
58 | ␉[smbe save:@"/tmp/chmIOreg.plist"];␊ |
59 | ␉NSLog(@"SMBIOS = \n%@", smbe); ␊ |
60 | ␊ |
61 | ␉// partitions extraction testing␊ |
62 | #if 1␊ |
63 | ␉NSArray* arr = [PartitionInfoElement createBSDPartitionList];␊ |
64 | ␉NSLog(@"List of existing bsd disk partitions:\n %@", arr);␊ |
65 | ␉␊ |
66 | ␉for (PartitionInfoElement* part in [PartsInfoMgr parts]) ␊ |
67 | {␊ |
68 | ␉␉NSLog(@"PartionBootable = %i\n%@", (int) [part isBootable], part);␊ |
69 | NSLog(@"boot info = %@", [part bootDescription] ) ;␊ |
70 | }␊ |
71 | /*␊ |
72 | ␉[PartsInfoMgr hideParts: @"\"Macintosh HD\" hd(0,3)"];␊ |
73 | ␉[PartsInfoMgr hideParts: @"disk0s2 hd(0,2) "];␊ |
74 | ␉[PartsInfoMgr hideParts: @"BOOTCAMP \"Macintosh HD\""];␊ |
75 | ␉[PartsInfoMgr hideParts: @"3E9C6A92-3737-4C0F-9003-20B2482D61FB"];␊ |
76 | */␊ |
77 | ␉[PartsInfoMgr renameParts: @"hd(0,2) \"Test\""];␊ |
78 | ␉[PartsInfoMgr renameParts: @"hd(0,3) Fantastic"];␊ |
79 | ␉[PartsInfoMgr renameParts: @"hd(0,4) \"A BC\"; hd(0,2) DEF"];␊ |
80 | ␉␊ |
81 | #else␊ |
82 | ␉testDiskInfoWith(@"disk0s2");␉␊ |
83 | ␉testDiskInfoWith(@"disk0s3");␉␊ |
84 | #endif␊ |
85 | ␊ |
86 | // flag substitutions testing␊ |
87 | fprintf(stderr, "String Test\n");␊ |
88 | std::string options = "-v darkwake ab= a=0 =abc -f";␊ |
89 | fprintf(stderr, "options = %s\n", options.c_str() );␊ |
90 | std::list<std::string> l = tokenize(options, " ");␊ |
91 | std::list<std::string>::const_iterator it = l.begin();␊ |
92 | for (; it != l.end(); it++)␊ |
93 | {␊ |
94 | std::string s = *it;␊ |
95 | std::cerr << "token: " << s ␊ |
96 | << ", left: " << string_left(s, "=") ␊ |
97 | << ", right: " << string_right(s, "=") ␊ |
98 | << ", trim: " << trim(s) ␊ |
99 | << std::endl;␊ |
100 | }␊ |
101 | ␊ |
102 | ␊ |
103 | ␊ |
104 | [pool drain];␊ |
105 | return 0;␊ |
106 | }␊ |
107 | |