Posts by Chang Park

Shells

bashsh

Shell is a program taking commands from a keyboard and giving them to operating system.

Below are three popular shells on Linux.

bash

  • Bourne Again Shell. The most commonly used shell on Linux.

tcsh

  • Enhanced C shell(csh).

zsh

  • The newest of the shells. Compatible with the Bourne shell. Has powerful completion features.

 

Virtual Consoles

linux terminal

Virtual Consoles enable multi-user logins on a single machine. For example, you can login with your account and also as a root.

 

By default, most Linux versions provide virtual consoles with these keys.

Ctrl + Alt + F1 – F6: Virtual Consoles

Ctl + Alt + F7: A console where X server is running.

 

X

  • is an application that manages one or more graphical displays and input devices(mouse, keyboard, etc.)
  • works as a server.

You have probably heard about X11, X server, or X window.

All of these mean the same, and X11 just means eleventh version of X.

 

You can use a command ‘w’ which shows a list of currently logged-in users. 

w result

tty represents regular terminal.

pts represents pseudo terminal slave(e.g. ssh connection).

 

 

Methodology: Qualitative vs. Quantitative

qualitative-vs-quantitative

These two terms can be used as research methods.

Qualitative

  • used to gain an understanding of underlying reasons, opinions, and motivations
  • provides insights into the problem or helps to develop ideas or hypotheses

Quantitative

  • used to quantify the problem by generating numerical data
  • uses measurable data to formulate facts and uncover patterns in research.
  • much more structured than qualitative.

 

How above methodologies can be applied in research project:

  1. Formulating hypotheses (Qualitative) – Can initiate a research by discovering the problems or opportunities people are thinking.
  2. Validating your hypotheses (Quantitative) – Can get numbers to apply statical analysis for validating hypotheses.
  3. Finding general answers (Quantitative) – Helps to get definite answers for broad questions.
  4. Incorporating the human element (Qualitative) – People’s own words can help to uncover blind spots.

 

 

Down Call vs. Up Call

downcall_upcall

Down Call

  • User code(unprivileged) enters to kernel with trap(interrupt).

Up Call

  • Kernel(privileged) enters to user code with IPC(Interprocess Communication).

 

White Box, Black Box, and Gray Box

black_and_white

In software testing, there are three different types of testing depending on how much knowledge the testers have on the software being tested.

White Box Testing

  • With full knowledge of the software. (internal structures, source codes, etc.)
  • Usually tests how the software performs.
  • Suitable for software developers.

Black Box Testing

  • Without having any knowledge of the software. (internal structures, source codes, etc.)
  • Usually tests for functionality of the software.
  • Suitable for third-party testers.

Gray Box Testing

  • Test with partial knowledge of the software.

Testing Methods

test

These are currently popular methods to test software.

Fuzz Testing

  • Input massive invalid, unexpected, or random data(Fuzz) to find errors or vulnerabilities in the software.
  • Effective on blackbox testing
  • Pros
    • Simple
    • Provides results with little effort
  • Cons
    • May miss bugs that don’t trigger a full program crash
    • May be less likely to trigger bugs that are only triggered in highly specific circumstances

 

Stochastic Testing

  • Input random sequence of datas 

 

Model-based Testing

  • Generates meaningful test case models which can detect errors on the desired behavior.

 

Symbolic Testing

  • Replace inputs of program with symbolic variables.
  • Track symbols rather than concrete input
  • When execution path diverges, fork and add constraints on symbolic values
  • Find the feasibility of all paths in the program.
  • Quite expensive for finding feasibility of path.
x = read();
if (x > 3) {
  y = 1;
  if (x < 0)
    y = 2;
} else y = 3;

After changing with symbolic variables, it checks the feasibility of paths. On above example, the expression (y = 2; on line #5) will not be reached.

  • Challenges
    • path explosion
      • Exponential in branching structure
      • Loop on symbolic variables
    • Complex code and environment dependencies
      • System calls
      • Library calls
      • Recursive calls
  • Possible Solutions
    • For “path Explosion”
      • Random search (e.g., randomly restart in a while loop, pick next path randomly), but check coverage implementation is required
      • Combined search
    • For “complex code and environment dependencies”
      • Simulate system call
      • Build simple versions of library calls
      • Run library an system calls with a concrete value
      • Summarize the loops
  • Applications:
    • Detecting infeasible paths
    • Generating test inputs
    • Finding bugs and vulnerabilities
    • Proving two code segments are equivalent (Code Hunt)

 

Concolic Testing (Concrete + Symbolic)

  • Input actual concrete value to the program, then generate new input by changing the path condition.
  • Less expensive than Symbolic testing.

 

A/B (or split, bucket) Testing

  • Comparing two versions of software which performs better
  • Statistical analysis which performed better

e.g.) randomly showing two different versions to users, and see which one had more uses

 

Boundary Testing

  • Extreme ends like Start- End, Lower- Upper, Maximum-Minimum, Just Inside-Just Outside values are called boundary values and the testing is called “boundary testing”.
  • Input variables are selected at their:
    • Minimum
    • Just above the minimum
    • A nominal value
    • Just below the maximum
    • Maximum
  • Boundary Testing comes after the Equivalence Class Partitioning.

 

Equivalence partitioning or equivalence class partitioning (ECP)

  • Software testing technique that divides the input data of a software unit into partitions of equivalent data from which test cases can be derived
  • In principle, test cases are designed to cover each partition at least once.
  • This technique tries to define test cases that uncover classes of errors, thereby reducing the total number of test cases that must be developed.
    • Pros: reduction in the time required for testing software due to lesser number of test cases

 

 

References

  • https://www.guru99.com/equivalence-partitioning-boundary-value-analysis.html
  • https://en.wikipedia.org/wiki/Equivalence_partitioning

What does the symbol ‘&’ mean in C and C++?

ampersand

‘&’ symbol has two meanings in C and C++.

  • Address of Operator: returns address of a variable.
    • int a = 3;
    • printf(“%d”, a);
      • will return value of a: 3
    • printf(“%d”, &a);
      • will return address of variable a.

 

  • Bit-wise Operator &: operates on bitlevel
    • Example:table_bitwise_operator
    • int a = 13&4;
      • 13 = 1101
      • 4  =0100
      • 13&4 = 0100
      • a = 4

compileSdkVersion, minSdkVersion, and targetSdkVersion

Screen Shot 2017-11-15 at 12.37.43 AM

compileSdkVersion

  • can choose which version of Android SDK to compile the app with
  • strongly recommended to compile with latest SDK (the app can use latest API)
  • this compile SDK will not be included in the app.
  • If using support library, the version should be matched with this compileSdkVersion.

 

minSdkVersion

  • lower bound of your app (minimum version of user devices the app can be installed).
  • Google Play Store uses to determine which devices the app can be installed on.
  • If using support libraries, it should be higher than the version of the support libraries.
    • On July 2017, minSdkVersion of all support libraries were increased to 14.
  • Check DashBoard to see current distribution of all Android versions.

 

targetSdkVersion

  • Indicates which Android version the app designed for.
  • Informs that developer tested the app against target SDK version.
  • If target SDK version is lower than running API version, system enables compatible behaviors to maintain the app’s forward compatibility.

 

Tips

compileSdkVersion = targetSdkVersion = latest Android Version

  • so that the app can work on latest Android version devices.

Recommend to check latest SDK and update the app

  • Set targetSdkversion and compileSdkVersion to latest version.
  • In that way, you can check if there will be any error when running the app on newer version.
  • You don’t need to use any new features of newer versions.

Euclid’s Algorithm

Screen Shot 2017-10-02 at 10.32.14 PM

Euclid’s(Euclidean) Algorithm

  • Algorithm to find GCD of two large numbers

GCD(N1, N2), suppose that N1 is larger than N2

N1 = N2 * q1 + r1   <– Larger number divide by Small number

N2 = r1 * q2 + r2   <– Small number divide by remainder of previous

r1 = r2 * q3 + r3

…….

N = r * q + 0    <– When remainder becomes zero, then r is the GCD

 

example

  • GCD(1701,3768)
    • 3768 = 1701*2 + 366
    • 1701 = 366*4 + 237
    • 366 = 237*1 + 129
    • 237 = 129*1 + 108
    • 129 = 108*1 + 21
    • 108 = 21*5  + 3
    • 21 = 3*7 + 0       <– 3 is the GCD of 1701, 3768

 

Deprecated APIs

3678.deprecated

Deprecated

  • As Android Versions keep being updated, many APIs and their methods are being revised.
  • Even though those API’s methods get deprecated, developers can still use the methods. (but they will see compiler’s warning)
  • However, developers are discouraged to keep using these methods because it is dangerous or there is better alternatives.

 

Example

deprecated