Git cpp bash: Difference between revisions

From Phobos Wiki
Jump to navigation Jump to search
(Uus lehekülg: '== GIT == * Save work progress in a repository ** For example [https://github.com/ github.com] * Use [http://nvie.com/posts/a-successful-git-branching-model/ branches] ** one for...')
 
No edit summary
 
Line 1: Line 1:
Elementary knowledge of GIT, BASH, C++ will be tested.
Task may be completed on any Linux distribution (recommended debian/ubuntu)
== GIT ==
== GIT ==
* Save work progress in a repository
* Save work progress in a repository
** For example [https://github.com/ github.com]
** For example [https://github.com/ github.com]
* Use [http://nvie.com/posts/a-successful-git-branching-model/ branches]
* Use branches ([http://nvie.com/posts/a-successful-git-branching-model/ help])
** one for implementing bash script and another for c++
** One branch for implementing bash script and another branch for c++
** commit often,  
** commit often, total number of commits should be 10+
** when checking out a random revision, it should compile.
** when checking out a random revision, it should compile.
*** for example first commit might be a simple "hello world".
** Branches start from master and must be merged back into master
** finished work should be merged into master
 
== BASH ==
== BASH ==
* awk
=== Script 1 - Show memory usage ===
* grep
* sed


=== Script 1 ===
Script has 1 optional argument, path to meminfo file (contains current memory status).
If it's not provided use '''/proc/meminfo'''


Script has 1 optional argument, path to meminfo file.
Use standard unix tools like '''awk''', '''grep''', '''sed''' to parse the input file.
If it's not provided use "/proc/meminfo"


Use standard unix tools like awk, grep, sed and others
Example of input file
 
cat /proc/meminfo
MemTotal:        7969612 kB
MemFree:        4582768 kB
Buffers:          707368 kB
Cached:          1122984 kB
SwapCached:            0 kB
Active:          1742408 kB
Inactive:        1203472 kB
[ ... ]


output:
output:
RAM: x MB used / y MB total ( z MB free)
./script1.sh /proc/meminfo
 
RAM: 4582 MB used / 7969 MB total ( 3387 MB free)
 
Example of /proc/meminfo
<pre>
cat /proc/meminfo
MemTotal:        7969612 kB
MemFree:        4582768 kB
Buffers:          707368 kB
Cached:          1122984 kB
SwapCached:            0 kB
Active:          1742408 kB
Inactive:        1203472 kB
Active(anon):    1115268 kB
Inactive(anon):  168692 kB
Active(file):    627140 kB
Inactive(file):  1034780 kB
Unevictable:          0 kB
Mlocked:              0 kB
SwapTotal:            0 kB
SwapFree:              0 kB
Dirty:              148 kB
Writeback:            0 kB
AnonPages:      1115604 kB
Mapped:          251420 kB
Shmem:            168440 kB
Slab:            288752 kB
SReclaimable:    256656 kB
SUnreclaim:        32096 kB
KernelStack:        3784 kB
PageTables:        36524 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:    3984804 kB
Committed_AS:    3669332 kB
VmallocTotal:  34359738367 kB
VmallocUsed:      563420 kB
VmallocChunk:  34359156568 kB
HardwareCorrupted:    0 kB
AnonHugePages:        0 kB
HugePages_Total:      0
HugePages_Free:        0
HugePages_Rsvd:        0
HugePages_Surp:        0
Hugepagesize:      2048 kB
DirectMap4k:      59392 kB
DirectMap2M:    8189952 kB
</pre>


=== Script 2 ===
=== Script 2 - compile c++ application ===


Compiles the C++ application
Compiles the C++ application
Probably only has 1 useful line, g++ with some linker options.
Probably only has 1 useful line, g++ with some linker options.
example:
./script2.sh
Compilation started
Compilation finished


== C++ ==
== C++ ==
 
=== List files in directory ===
* [http://www.boost.org/ boost]
** datetime
** format
** filesystem (3)
 
=== Application ===
 
Program takes one argument: path to directory.
Program takes one argument: path to directory.
Outputs list of files.


Application must print out the name of directory.
Application must print out the name of directory.
Line 92: Line 56:
At the end, show total run time.
At the end, show total run time.


Use boost libraries: format, datetime, filesystem.
Use [http://www.boost.org/ boost] libraries: [http://www.boost.org/doc/libs/1_53_0/libs/format/doc/format.html format], [http://www.boost.org/doc/libs/1_53_0/doc/html/date_time.html date_time], [http://www.boost.org/doc/libs/1_53_0/libs/filesystem/doc/index.htm filesystem].


Output format:
Output format:
./prog /path/to/directory
  List of files in '/path/to/directory'
  List of files in '/path/to/directory'
  Time: 00:00:00.123456 file: 'filename1'
  Time: 00:00:00.123456 file: 'filename1'
  Time: 00:00:01.123456 file: 'filename1'
  Time: 00:00:01.123456 file: 'filename2'
  Time: 00:00:02.123456 file: 'filename1'
  Time: 00:00:02.123456 file: 'filename3'
  Total running time was: 00:00:10.654321
  Total running time was: 00:00:10.654321

Latest revision as of 16:23, 6 March 2013

Elementary knowledge of GIT, BASH, C++ will be tested.

Task may be completed on any Linux distribution (recommended debian/ubuntu)

GIT

  • Save work progress in a repository
  • Use branches (help)
    • One branch for implementing bash script and another branch for c++
    • commit often, total number of commits should be 10+
    • when checking out a random revision, it should compile.
    • Branches start from master and must be merged back into master

BASH

Script 1 - Show memory usage

Script has 1 optional argument, path to meminfo file (contains current memory status). If it's not provided use /proc/meminfo

Use standard unix tools like awk, grep, sed to parse the input file.

Example of input file

cat /proc/meminfo 
MemTotal:        7969612 kB
MemFree:         4582768 kB
Buffers:          707368 kB
Cached:          1122984 kB
SwapCached:            0 kB
Active:          1742408 kB
Inactive:        1203472 kB
[ ... ]

output:

./script1.sh /proc/meminfo
RAM: 4582 MB used / 7969 MB total ( 3387 MB free)

Script 2 - compile c++ application

Compiles the C++ application Probably only has 1 useful line, g++ with some linker options.

example:

./script2.sh
Compilation started
Compilation finished

C++

List files in directory

Program takes one argument: path to directory. Outputs list of files.

Application must print out the name of directory. List all files in that directory. Each line must be preceded with the current running time of application. At the end, show total run time.

Use boost libraries: format, date_time, filesystem.

Output format:

./prog /path/to/directory
List of files in '/path/to/directory'
Time: 00:00:00.123456 file: 'filename1'
Time: 00:00:01.123456 file: 'filename2'
Time: 00:00:02.123456 file: 'filename3'
Total running time was: 00:00:10.654321