1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
/*******************************************************************************
* Copyright (c) 2009 Red Hat, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat - initial API and implementation
*******************************************************************************/
package org.eclipse.linuxtools.callgraph.launch.tests;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.linuxtools.internal.callgraph.core.SystemTapErrorHandler;
import org.junit.Before;
import org.junit.Test;
public class SystemTapErrorHandlerTest {
private SystemTapErrorHandler errHandler;
private String errorString;
@Before
public void setUp() {
errHandler = new SystemTapErrorHandler();
}
@Test
public void testErrorNotRecognized(){
errorString = "This error will not be caught \n" +
"Not even this one \n" +
"Unrecognized \n" +
"Not found \n" +
"Error";
errHandler.handle(new NullProgressMonitor(), errorString);
assertFalse(errHandler.isErrorRecognized());
}
@Test
public void testErrorRecognized(){
errorString = "As long as the word stapusr or stapdev is here, error is recognized";
errHandler.handle(new NullProgressMonitor(), errorString);
assertTrue(errHandler.isErrorRecognized());
}
@Test
public void testUserGroupError(){
errorString = "ERROR: You are trying to run systemtap as a normal user.\n" +
"You should either be root, or be part of the group \"stapusr\" and " +
"possibly one of the groups \"stapsys\" or \"stapdev\".";
errHandler.handle(new NullProgressMonitor(), errorString);
assertTrue(errHandler.isErrorRecognized());
assertTrue(errHandler.getErrorMessage().contains("Please add yourself to the 'stapdev' or 'stapusr' group in order to run stap."));
}
@Test
public void testDebugInfoError(){
errorString = "missing [architecture] kernel/module debuginfo under '[kernel-build-tree]'";
errHandler.handle(new NullProgressMonitor(), errorString);
assertTrue(errHandler.isErrorRecognized());
assertTrue(errHandler.getErrorMessage().contains("No debuginfo could be found. Make sure you have yum-utils installed, and run debuginfo-install kernel as root."));
}
@Test
public void testUprobesError(){
errorString = "SystemTap's version of uprobes is out of date. As root, or a member of the 'root' group, run \"make -C /usr/local/share/systemtap/runtime/uprobes\".";
errHandler.handle(new NullProgressMonitor(), errorString);
assertTrue(errHandler.isErrorRecognized());
System.out.println(errHandler.getErrorMessage());
assertTrue(errHandler.getErrorMessage().contains("SystemTap's version of uprobes is out of date."));
assertTrue(errHandler.getErrorMessage().contains("make -C /usr/local/share/systemtap/runtime/uprobes\"."));
}
}
|