Search in sources :

Example 6 with TreeParent

use of org.eclipse.linuxtools.internal.perf.model.TreeParent in project linuxtools by eclipse.

the class ModelTest method doubleClickAllChildren.

/**
 * Performs a Perf double-click action on every element in the
 * TreeViewer model.
 *
 * @param root some element that will serve as the root
 * @param tv a TreeViewer containing elements from the Perf model
 * @param dblClick the double-click action to perform on every
 * element of the TreeViewer.
 */
private void doubleClickAllChildren(TreeParent root, TreeViewer tv, PerfDoubleClickAction dblClick) {
    for (TreeParent child : root.getChildren()) {
        // see PerfDoubleClickAction for IStructuredSelection
        tv.setSelection(new StructuredSelection(child));
        dblClick.run();
        doubleClickAllChildren(child, tv, dblClick);
    }
}
Also used : TreeParent(org.eclipse.linuxtools.internal.perf.model.TreeParent) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection)

Example 7 with TreeParent

use of org.eclipse.linuxtools.internal.perf.model.TreeParent in project linuxtools by eclipse.

the class ModelTest method testPercentages.

@Test
public void testPercentages() {
    TreeParent invisibleRoot = buildModel("resources/defaultevent-data/perf.data", "resources/defaultevent-data/perf.data.txt", "resources/defaultevent-data/perf.data.err.log");
    checkChildrenPercentages(invisibleRoot, invisibleRoot.getPercent());
}
Also used : TreeParent(org.eclipse.linuxtools.internal.perf.model.TreeParent) Test(org.junit.Test) AbstractTest(org.eclipse.linuxtools.profiling.tests.AbstractTest)

Example 8 with TreeParent

use of org.eclipse.linuxtools.internal.perf.model.TreeParent in project linuxtools by eclipse.

the class ModelTest method testDoubleClickAction.

@Test
public void testDoubleClickAction() {
    TreeParent invisibleRoot = buildModel("resources/defaultevent-data/perf.data", "resources/defaultevent-data/perf.data.txt", "resources/defaultevent-data/perf.data.err.log");
    PerfPlugin.getDefault().setModelRoot(invisibleRoot);
    // update the model root for the view
    PerfCore.refreshView("resources/defaultevent-data/perf.data");
    // number of parents excluding invisibleRoot
    int numOfParents = getNumberOfParents(invisibleRoot) - 1;
    // create a double click action to act on the tree viewer
    try {
        PerfProfileView view = (PerfProfileView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(PerfPlugin.VIEW_ID);
        TreeViewer tv = view.getTreeViewer();
        PerfDoubleClickAction dblClick = new PerfDoubleClickAction(tv);
        // double click every element
        doubleClickAllChildren(invisibleRoot, tv, dblClick);
        // If all elements are expanded, this is the number of elements
        // in our model that have children.
        assertEquals(numOfParents, tv.getExpandedElements().length);
    } catch (PartInitException e) {
        fail("Failed to open the Profiling View.");
    }
}
Also used : PerfProfileView(org.eclipse.linuxtools.internal.perf.ui.PerfProfileView) TreeParent(org.eclipse.linuxtools.internal.perf.model.TreeParent) TreeViewer(org.eclipse.jface.viewers.TreeViewer) PartInitException(org.eclipse.ui.PartInitException) PerfDoubleClickAction(org.eclipse.linuxtools.internal.perf.ui.PerfDoubleClickAction) Test(org.junit.Test) AbstractTest(org.eclipse.linuxtools.profiling.tests.AbstractTest)

Example 9 with TreeParent

use of org.eclipse.linuxtools.internal.perf.model.TreeParent in project linuxtools by eclipse.

the class ModelTest method testParserMultiEvent.

@Test
public void testParserMultiEvent() {
    TreeParent invisibleRoot = buildModel("resources/multievent-data/perf.data", "resources/multievent-data/perf.data.txt", "resources/multievent-data/perf.data.err.log");
    assertEquals(invisibleRoot.getChildren().length, 5);
    String cur = null;
    for (TreeParent event : invisibleRoot.getChildren()) {
        cur = event.getName();
        // Assert specific properties extracted by the parser.
        if ("cpu-clock".equals(cur)) {
            assertTrue(event.hasChildren());
            assertEquals(event.getChildren().length, 1);
            TreeParent cmd = event.getChildren()[0];
            assertEquals(cmd.getChildren().length, 1);
            String[] cmdLabels = { "hellotest" };
            checkCommadLabels(cmdLabels, cmd);
        } else if ("task-clock".equals(cur)) {
            assertTrue(event.hasChildren());
            assertEquals(event.getChildren().length, 1);
            TreeParent cmd = event.getChildren()[0];
            assertEquals(cmd.getChildren().length, 1);
            String[] cmdLabels = { "hellotest" };
            checkCommadLabels(cmdLabels, cmd);
        } else if ("page-faults".equals(cur)) {
            assertTrue(event.hasChildren());
            assertEquals(event.getChildren().length, 1);
            TreeParent cmd = event.getChildren()[0];
            assertEquals(cmd.getChildren().length, 3);
            String[] cmdLabels = { "ld-2.14.90.so", "[kernel.kallsyms]", "libc-2.14.90.so" };
            checkCommadLabels(cmdLabels, cmd);
        } else if ("minor-faults".equals(cur)) {
            assertTrue(event.hasChildren());
            assertEquals(event.getChildren().length, 1);
            TreeParent cmd = event.getChildren()[0];
            assertEquals(cmd.getChildren().length, 3);
            String[] cmdLabels = { "ld-2.14.90.so", "[kernel.kallsyms]", "libc-2.14.90.so" };
            checkCommadLabels(cmdLabels, cmd);
        } else if ("major-faults".equals(cur)) {
            assertFalse(event.hasChildren());
        }
    }
}
Also used : TreeParent(org.eclipse.linuxtools.internal.perf.model.TreeParent) Test(org.junit.Test) AbstractTest(org.eclipse.linuxtools.profiling.tests.AbstractTest)

Example 10 with TreeParent

use of org.eclipse.linuxtools.internal.perf.model.TreeParent in project linuxtools by eclipse.

the class ModelTest method buildModel.

/**
 * Build model based on perf data file report.
 * @param perfDataLoc location of perf data file
 * @param perfTextDataLoc location of perf data text file
 * @param perfErrorDataLoc location of error log file
 * @return tree model based on perf data report.
 */
private TreeParent buildModel(String perfDataLoc, String perfTextDataLoc, String perfErrorDataLoc) {
    TreeParent invisibleRoot = new TreeParent("");
    BufferedReader input = null;
    BufferedReader error = null;
    try {
        input = new BufferedReader(new FileReader(perfTextDataLoc));
        error = new BufferedReader(new FileReader(perfErrorDataLoc));
    } catch (IOException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
    PerfCore.parseReport(config, null, null, perfDataLoc, null, invisibleRoot, false, input, error);
    return invisibleRoot;
}
Also used : TreeParent(org.eclipse.linuxtools.internal.perf.model.TreeParent) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) IOException(java.io.IOException)

Aggregations

TreeParent (org.eclipse.linuxtools.internal.perf.model.TreeParent)14 AbstractTest (org.eclipse.linuxtools.profiling.tests.AbstractTest)7 Test (org.junit.Test)7 BufferedReader (java.io.BufferedReader)4 IOException (java.io.IOException)3 FileReader (java.io.FileReader)2 InputStreamReader (java.io.InputStreamReader)2 ArrayList (java.util.ArrayList)2 IPath (org.eclipse.core.runtime.IPath)2 PMCommand (org.eclipse.linuxtools.internal.perf.model.PMCommand)2 PMDso (org.eclipse.linuxtools.internal.perf.model.PMDso)2 PMFile (org.eclipse.linuxtools.internal.perf.model.PMFile)2 PMSymbol (org.eclipse.linuxtools.internal.perf.model.PMSymbol)2 Stack (java.util.Stack)1 IProject (org.eclipse.core.resources.IProject)1 CoreException (org.eclipse.core.runtime.CoreException)1 Path (org.eclipse.core.runtime.Path)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 PMEvent (org.eclipse.linuxtools.internal.perf.model.PMEvent)1