Chameleon Applications

Chameleon Applications Svn Source Tree

Root/trunk/ChameleonPrefPane/test_util/test_util.mm

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
18void testDiskInfoWith(NSString * bsd)
19{
20PartitionInfoElement* di = [[PartitionInfoElement alloc] initWithBSDName: bsd];
21
22if ([di isValid] && [di.vUUID length] >0)
23{
24#if 1
25NSLog(@"bsdName %@", [di bsdName] );
26NSLog(@"deviceProtocol %@", [ di devProtocol] );
27NSLog(@"volumeName %@", [di vName]);
28NSLog(@"volumePath %@", [di vPath]);
29NSLog(@"volumeKind %@", [di vKind]);
30NSLog(@"deviceInternal %i", (int) [ di devInternal] );
31NSLog(@"volumeUUID %@", [di vUUID]);
32NSLog(@"mediaPath %@", [di mediaPath]);
33NSLog(@"mediaRemovable %i", (int) [di mediaRemovable]);
34
35NSLog(@"\n");
36
37#else
38int i = 0;
39for (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
52int main (int argc, const char * argv[])
53{
54 NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
55
56 // smbios extractio testing
57SmbiosExtractor* smbe = [[SmbiosExtractor alloc] init];
58[smbe save:@"/tmp/chmIOreg.plist"];
59NSLog(@"SMBIOS = \n%@", smbe);
60
61// partitions extraction testing
62#if 1
63NSArray* arr = [PartitionInfoElement createBSDPartitionList];
64NSLog(@"List of existing bsd disk partitions:\n %@", arr);
65
66for (PartitionInfoElement* part in [PartsInfoMgr parts])
67 {
68NSLog(@"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
82testDiskInfoWith(@"disk0s2");
83testDiskInfoWith(@"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

Archive Download this file

Revision: 460